Intended Usage
This method is intended to be used by client and server applications, to duplicate object references (both pointers to local implementation objects and proxies to remote objects). For each duplication performed on an object reference, an equal number of alls to CORBA::release must also be made for the reference to be deleted.
When an application passes an object reference (either a local object or a proxy) on a method call, either as a parameter value or a return result, if the call transfers ownership of the object reference and the application needs to retain ownership of the reference as well, the application should first duplicate the reference before passing it. Each user of the reference should subsequently CORBA::release the reference so that its resources can be reclaimed.
When CORBA::Object::_duplicate is called on a proxy object, only the proxy is affected; no remote invocation is made to the remote object to which the proxy refers. Hence, CORBA::Object::_duplicate and CORBA::release are only used to manage the local resources associated with object references.
Syntax
static CORBA::Object_ptr _duplicate (CORBA::Object_ptr obj);
Input parameters
Return values
Example
/*The following example is written in C++*/ #include "corba.h" /* this function returns duplicate of an object ref */ ::CORBA::Object_ptr getObj(::CORBA::Object_ptr p) { return CORBA::Object::_duplicate(p); }