The CORBA 2.1 C++ client bindings define a variety of C++ types corresponding to a single Interface Definition Language (IDL) interface. The following is a list of these interfaces:
For example, an IDL interface I is mapped to C++ client types. The types named I and I_var are classes. The type I_ptr (the object reference) is defined in the IBM Object Request Broker (ORB) as an I*.
The class I is referred to as the interface class corresponding to the IDL interface named I. The IDL constructs defined within the IDL interface I are defined with public access within the C++ class I. For example, the operations within an IDL interface are mapped as C++ virtual member methods within the corresponding C++ class.
As with other user-defined IDL types, the I_var type is used to assist storage management. Specifically, an I_var type holds an I_ptr and can be used as if it were an I_ptr. When an I_var type is assigned a new value or when it goes out of scope, it releases the I_ptr it is holding at that time.
The CORBA specification prohibits CORBA-compliant applications from the following:
I my_instance; // NOT ALLOWED! I_ptr my_instance = new I; // NOT ALLOWED!
Instead, the I_ptr, and I_var types must be used to hold object references and object references can be created only by client applications by invoking methods that return object references. The interface class I is used by client applications only as a name scope.
IDL operations defined in (or inherited by) interface I are invoked in C++ using the arrow (->) operator on either an I_ptr, IRef, or I_var type.
Nil object references of type I_ptr can be obtained using a static member function of I called _nil(). Operations cannot be invoked on nil object references. The CORBA::is_nil function is the only CORBA-conformant way to determine whether a given object reference is nil. CORBA::release can be invoked on a nil object reference, but is not needed. The _duplicate and _narrow functions defined by the C++ bindings can be given a nil object reference.
In the IBM C++ bindings, the CORBA-prescribed types are implemented as follows:
For more details on C++ bindings for CORBA interfaces, see the following topics: