15.4 Implementing Operations
The signature of an implementation member function is the mapped signature of the OMG IDL operation. Unlike the client-side mapping, the OMG specifies that the function header for the server-side mapping include the appropriate exception specification. The following code snippet illustrates an example of an exception specification.
// IDL
interface A
{
exception B {};
void f() raises(B);
};
// C++
class MyA : public virtual POA_A
{
public:
void f();
...
};
Since all operations and attributes may raise CORBA system
exceptions, CORBA::SystemException
must appear in all
exception specifications, even when an operation has no
raises
clause.
Note:
Because of the differences in C++ compilers, it is best to leave out the "throw declaration" in the method signature. Some systems cause the application server to crash if an undeclared exception is thrown in a method that has declared the exceptions it will throw.Within a member function, the “this” pointer refers to the implementation object’s data as defined by the class. In addition to accessing the data, a member function may implicitly call another member function defined by the same class. The following code snippet illustrates an example of calling another member function.
// IDL
interface A
{
void f();
void g();
};
// C++
class MyA : public virtual POA_A
{
public:
void f();
void g();
private:
long x_;
};
void
MyA::f();
{
x_ = 3;
g();
}
When a servant member function is invoked in this manner, it is being called simply as a C++ member function, not as the implementation of an operation on a CORBA object.
Parent topic: Server Side Mapping