All classes created from an IDL can be manipulated by several methods of the CORBA::ORB
interface. The following section describes two of the most used methods from the ORB interface.
Following is the ORB class declaration:
class CORBA { class ORB { public: char* object_to_string (Object_ptr); Object_ptr string_to_object (const Identifier); }; };
Because an object reference is opaque and may differ from ORB to ORB, the object reference is not a convenient value for persistent storage of references to objects or for communicating references by means other than invocation. Two problems must be solved:
An object reference can be translated into a string by the object_to_string
operation. The value may be stored or communicated in whatever ways strings may be manipulated. Subsequently, the string_to_object
operation will accept a string produced by object_to_string
and return the corresponding object reference. The mapping usage is described in the following sections.
This member function produces a string representation of an object reference. The calling program must use the CORBA::string_free
member function to free the string memory after it is no longer needed.
For example:
Account_ptr ap = new Account("123"); char* accountstring = Account::orb( )->object_to_string(ap);
This member function creates an object reference, given a specified string. The string will usually have been obtained by calling the CORBA::ORB::object_to_string
member function.
For example:
Account_ptr ap = new Account("2345"); char* accountstring = Account::orb( )->object_to_string(ap); Account_ptr ap2 = Account::orb( )->string_to_object(accountstring);