NonStop Software

Object Reference String Operations

Previous Topic | Next Topic | Contents | Index
Getting Started Guide | Administration Guide | Programmer's Guide

Subtopics

ORB Class Declaration
Converting Object References to Strings

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.

ORB Class Declaration

Following is the ORB class declaration:

class CORBA
{
class ORB
{
public:
    char*  object_to_string (Object_ptr);
    Object_ptr  string_to_object (const Identifier);
  };
};

Converting Object References to Strings

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.

CORBA::ORB::object_to_string(CORBA::Object_ptr ObjRef)

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);

CORBA::ORB::string_to_object(const CORBA::Identifier ObjRefString);

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);

Previous Topic | Next Topic | Contents | Top
Getting Started Guide | Administration Guide | Programmer's Guide
Bibliography | Index | Glossary
© Tandem, a division of Compaq. All rights reserved. Legal notices.