Programming CORBA with Orbacus on Linux
Method calls
Method parameters
Much CORBA functions have signatures like the following:
S::f(X_ptr arg)
The C++ mapping ensures that both of the following invokations are possible:
X_ptr xp;
X_var xv;
s->f(xp);
s->f(xv);
You can clarify the roles of a parameter (in, inout or out)
by specifying it with some standard CORBA methods. If some functions have signatures
similiar to the following:
void S::fin(in X_ptr arg) // in parameter
void S::finout(inout X_ptr& arg) // inout parameter
void S::fout(out X_ptr& arg) // out parameter
calls like the ones above are possible:
X_ptr xp;
s->fin(xp.in());
s->finout(xp.inout());
s->fout(xp.out());
The functions clarifies the roles of each argument and helps C++ compilers with unclear
converion rules.
Return values
If a method wants to return a reference, there is another auxiliary method _retn()
which helps you to get proper reference counter handling: the method removes the ownership
of a _var reference without decrementing the reference count.
A typical usage for a signature like
X_ptr S::f()
is the following:
X_ptr S::f(){
X_var ret = <get reference from somewhere>
return ret._retn();
}
The _retn() method removes the ownership (the responsibility for memory management)
from the method f() without destroying the object. The caller which gets the returned
reference is now responsible for it. It is therefore convenient to use another _var
variable to hold the result and automatically release it:
X_var resv;
resv = s->f();
back to CORBA page
|