An operation within an interface is mapped to a C++ member function with the same name as the IDL operation.
If an operation has a context specification, a Context_ptr
input parameter must follow the operation's arguments.
IDL Attributes
A read-write attribute maps to two C++ member functions with the same name as the attribute. One of the functions sets the attribute value and the other gets the attribute value. A readonly attribute maps to a single member function that gets the attribute's value.
Parameters and return types follow normal rules for passing parameters.
//IDL interface Customer { readonly attribute float amtDue; attribute long custNo; void makeDeposit(in float sum); void makeWithdrawal (in float sum, out float balDue); }; interface Editing { Customer newCustomer(in string name); }; |
The following code is the equivalent C++ mapping:
//C++ class Customer : public virtual CORBA::Object { public: virtual CORBA::Float amtDue( ); virtual CORBA::Long custNo( ); virtual CORBA::void custNo( CORBA::Long custNo); virtual void makeDeposit(CORBA::Float_out sum); virtual void makeWithdrawal(CORBA::Float_out sum, CORBA::Float_out balDue); } class Editing : public virtual CORBA::Object { public: virtual Customer_ptr newCustomer( const char* name); } |
C++ member functions have default parameters of type CORBA::Environment
. This value can be changed within the definition of IDL C++ classes.
The newCustomer( )
operation includes an object reference return type: Customer
. The C++ code for newCustomer( )
includes the object reference return type mapped to Customer_ptr
. The Customer_ptr
is an object reference for the C++ type Customer
and is defined as follows:
//C++ typedef Customer* Customer_ptr;
C++ mapping for oneway operations is the same as for any other operations except oneway operations do not have inout or out parameters. Oneway operations return void and only system exceptions may occur (not user-defined exceptions).
//C++ //Code for client Customer_var x; Editing_var y; //Bind y to an object of type Editing . . . x = y->newCustomer("Bryer"); x->newOrder(775.00); . . . |