Homepage of Ingo Klöckl
 Home
 Programmieren
 - Toolbox
 - Java
 - PostScript
 - Perl
 - Assembler
 - Links
 - Download
Ingo Klöckl
i.kloeckl@2k-software.de

Programming CORBA with Orbacus on Linux

Mixed use of _ptr and _var classes

References of both types are equivalent for invoke remote methods:

X_ptr xp = <get reference from somewhere>
X_var xv = <get reference from somewhere>
xp->f();  // ok
xv->f();  // ok and identical

When mixed assignments occurs, the following rules-of-thumb can be used to determine the consequences for the reference counter of the objects:

X_ptr xp = <get reference from somewhere>
X_ptr xp1;
X_var xv = <get reference from somewhere>
X_var xv1;

xp1 = xp;  // shallow copy
xp = xv;   // shallow copy, xv retains ownership
xv = xp;   // shallow copy, xv takes ownership
xv1 = xv;  // deep copy using _duplicate, xv1 takes ownership
           // of new reference
You can see that most assignments does not change the reference counter of the underlying server object. If either the source or the target is a _var pointer, you can happily assume that automatic and proper relasing of the reference takes place when the _var reference goes out of scope. In these cases you have to note that xv may goes out of scope, leaving xp dangling!

However, no special attention must be paied for the case of two _var references because the increase of the reference counter of the server objects comes in hand with the automatic release of the objects for both references. This is a safe assignments if a server object is used in different scopes.

back to CORBA page