Previous Table of Contents Next


5.2.5 Substitutability Issues


   The substitutability requirements for CORBA require the definition of what happens when an instance of a derived value type is passed as a parameter that is declared to be a base value type or an instance of a value type that supports an interface is passed as a parameter that is declared as the interface type.

   There are three cases to consider: the parameter type is a regular interface, the parameter type is an abstract interface, and the parameter type is a value type.

   5.2.5.1 Value instance -> Interface type

   A value type that supports a regular interface is not a subtype of that interface, and hence cannot be substituted for that interface in an invocation parameter. In this case an object reference corresponding to the value type instance that has been registered with the ORB must be obtained and this object reference must be used as the actual parameter. Different language mappings provide different facilities to aid in such parameter passing.

   5.2.5.2 Value Instance -> Abstract interface type

   A value type that supports an abstract interface is a subtype of that interface, and can be substituted for that interface in an invocation parameter.

   5.2.5.3 Value instance -> Value type

   In this case the receiving context is expecting to receive a value type. If the receiving context currently has the appropriate implementation class then there is no problem.

   If the receiving context does not currently hold an implementation with which to reconstruct the original type then the following algorithm is used to find such an implementation:

   Truncatability is a transitive property.

   Example

   valuetype EmployeeRecord { // note this is not a CORBA::Object // state definition private string name; private string email; private string SSN; // initializer factory init(in string name, in string SSN);

   };

   valuetype ManagerRecord: truncatable EmployeeRecord { // state definition private sequence<EmployeeRecord> direct_reports;

   };