Previous | Table of Contents | Next |
The PIDL interface for TypeCodes is as follows:
module CORBA {
enum TCKind { tk_null, tk_void, tk_short, tk_long, tk_ushort, tk_ulong, tk_float, tk_double, tk_boolean, tk_char, tk_octet,
tk_any, tk_TypeCode, tk_Principal, tk_objref, tk_struct, tk_union, tk_enum, tk_string, tk_sequence, tk_array, tk_alias, tk_except,
tk_longlong, tk_ulonglong, tk_longdouble, tk_wchar, tk_wstring, tk_fixed, tk_value, tk_value_box, tk_native, tk_abstract_interface,
tk_local_interface, tk_component, tk_home, tk_event
};
typedef short ValueModifier; const ValueModifier VM_NONE = 0; const ValueModifier VM_CUSTOM = 1; const ValueModifier VM_ABSTRACT
= 2; const ValueModifier VM_TRUNCATABLE = 3;
interface TypeCode {
exception Bounds {};exception BadKind {};
// for all TypeCode kindsboolean equal (in TypeCode tc);
boolean equivalent(in TypeCode tc);TypeCode get_compact_typecode();
TCKind kind ();
// for tk_objref, tk_struct, tk_union, tk_enum, tk_alias,// tk_value, tk_value_box, tk_native, tk_abstract_interface// tk_local_interface, tk_except// tk_component, tk_home and tk_eventRepositoryId id () raises (BadKind);
// for tk_objref, tk_struct, tk_union, tk_enum, tk_alias,// tk_value, tk_value_box, tk_native, tk_abstract_interface// tk_local_interface, tk_except// tk_component, tk_home and tk_eventIdentifier name () raises (BadKind);
// for tk_struct, tk_union, tk_enum, tk_value, // tk_except and tk_eventunsigned long member_count () raises (BadKind);Identifier member_name (in unsigned long index)
raises(BadKind, Bounds);
// for tk_struct, tk_union, tk_value, // tk_except and tk_eventTypeCode member_type (in unsigned long index)
raises (BadKind, Bounds);
// for tk_unionany member_label (in unsigned long index)
raises(BadKind, Bounds); TypeCode discriminator_type () raises (BadKind); long default_index () raises (BadKind);
// for tk_string, tk_wstring, tk_sequence, and tk_arrayunsigned long length () raises (BadKind);
// for tk_sequence, tk_array, tk_value_box and tk_aliasTypeCode content_type () raises (BadKind);
// for tk_fixedunsigned short fixed_digits() raises(BadKind);short fixed_scale() raises(BadKind);
// for tk_value and tk_event
Visibility member_visibility(in unsigned long index)
raises(BadKind, Bounds);
ValueModifier type_modifier() raises(BadKind);
TypeCode concrete_base_type() raises(BadKind);
}; };
With the above operations, any TypeCode can be decomposed into its constituent parts. The BadKind exception is raised if an
operation is not appropriate for the TypeCode kind it invoked.
The equal operation can be invoked on any TypeCode. The equal operation returns TRUE if and only if for the target TypeCode
and the TypeCode passed through the parameter tc, the set of legal operations is the same and invoking any operation from
that set on the two TypeCodes return identical results.
The equivalent operation is used by the ORB when determining type equivalence for values stored in an IDL any. TypeCodes are
considered equivalent based on the following semantics:
• If the result of the kind operation on either TypeCode is tk_alias, recursively replace the TypeCode with the result of calling content_type, until the kind is no longer tk_alias.
• If results of the kind operation on each typecode differ, equivalent returns false.
•If the id operation is valid for the TypeCode kind, equivalent returns TRUE if the results of id for both TypeCodes are non-empty strings and both strings are equal. If both ids are non-empty but are not equal, then equivalent returns FALSE. If either or both id is an empty string, or the TypeCode kind does not support the id operation, equivalent will perform a structural comparison of the TypeCodes by comparing the results of the other TypeCode operations in the following bullet items (ignoring aliases as described in the first bullet.). The structural comparison only calls operations that are valid for the given TypeCode kind. If any of these operations do not return equal results, then equivalent returns FALSE. If all comparisons are equal, equivalent returns true.
• The results of the name and member_name operations are ignored and not compared.
• The results of the member_count, default_index, length, digits, scale, and type_modifier operations are compared.
• The results of the member_label operation for each member index of a union TypeCode are compared for equality. Note that this means that unions whose members are not defined in the same order are not considered structurally equivalent.
• The results of the discriminator_type, member_type, and concrete_base_type operation and for each member index, and the result of the content_type operation are compared by recursively calling equivalent.
• The results of the member_visibility operation are compared for each member index.
Applications that need to distinguish between a type and different aliases of that type can supplement equivalent by directly
invoking the id operation and comparing the results.
The get_compact_typecode operation strips out all optional name and member name fields, but it leaves all alias typecodes
intact.
The kind operation can be invoked on any TypeCode. Its result determines what other operations can be invoked on the TypeCode.
The id operation can be invoked on object reference, valuetype, boxed valuetype, abstract interface, local interface, native,
structure, union, enumeration, alias, exception, component, home, and event TypeCodes. It returns the RepositoryId globally
identifying the type. Object reference, valuetype, boxed valuetype, native, exception, component, home, and event TypeCodes
always have a RepositoryId. Structure, union, enumeration, and alias TypeCodes obtained from the Interface Repository or the
ORB::create_operation_list operation also always have a RepositoryId. Otherwise, the id operation can return an empty string.
When the id operation is invoked on an object reference TypeCode that contains a base Object, the returned value is IDL:omg.org/CORBA/Object:1.0.
When it is invoked on a valuetype TypeCode that contains a ValueBase, the returned value is IDL:omg.org/CORBA/ValueBase:1.0.
When it is invoked on a component TypeCode that contains a Components::CCMObject, the returned value is IDL:omg.org/Components/CCMObject:1.0.
When it is invoked on a home TypeCode that contains a Components::CCMHome, the returned value is IDL:omg.org/Components/CCMHome:1.0.
When it is invoked on an eventtype TypeCode that contains a Components::EventBase, the returned value is IDL:omg.org/Components/EventBase:1.0.
The name operation can also be invoked on object reference, structure, union, enumeration, alias, abstract interface, local
interface, value type, boxed valuetype, native, and exception TypeCodes. It returns the simple name identifying the type within
its enclosing scope. Since names are local to a Repository, the name returned from a TypeCode may not match the name of the
type in any particular Repository, and may even be an empty string.
The order in which members are presented in the interface repository is the same as the order in which they appeared in the
IDL specification, and this ordering determines the index value for each member. The first member has index value 0. For example
for a structure definition:
struct example {
short member1;
short member2;
long member3;
};
In this example member1 has index = 0, member2 has index = 1, and member3 has index = 2. The value of member_count in this
case is 3.
The member_count and member_name operations can be invoked on structure, union, non-boxed valuetype, non-boxed eventtype,
exception, and enumeration TypeCodes. Member_count returns the number of members constituting the type. Member_name returns
the simple name of the member identified by index. Since names are local to a Repository, the name returned from a TypeCode
may not match the name of the member in any particular Repository, and may even be an empty string.
The member_type operation can be invoked on structure, non-boxed valuetype, non-boxed eventtype, exception and union TypeCodes.
It returns the TypeCode describing the type of the member identified by index.
The member_label, discriminator_type, and default_index operations can only be invoked on union TypeCodes. Member_label returns
the label of the union member identified by index. For the default member, the label is the zero octet. The discriminator_type
operation returns the type of all non-default member labels. The default_index operation returns the index of the default
member, or -1 if there is no default member.
The member_visibility operation can only be invoked on non-boxed valuetype and non-boxed eventtype, TypeCodes. It returns
the Visibility of the valuetype/eventtype member identified by index.
The member_name, member_type, member_label and member_visibility operations raise Bounds if the index parameter is greater
than or equal to the number of members constituting the type.
The content_type operation can be invoked on sequence, array, boxed valuetype and alias TypeCodes. For sequences and arrays,
it returns the element type. For aliases, it returns the original type. For boxed valuetype, it returns the boxed type.
An array TypeCode only describes a single dimension of an OMG IDL array. Multidimensional arrays are represented by nesting
TypeCodes, one per dimension. The outermost tk_array Typecode describes the leftmost array index of the array as defined in
IDL. Its content_type describes the next index. The innermost nested tk_array TypeCode describes the rightmost index and the
array element type.
The type_modifier and concrete_base_type operations can be invoked on non-boxed valuetype and non-boxed eventtypeTypeCodes.
The type_modifier operation returns the ValueModifier that applies to the valuetype/eventtype represented by the target TypeCode.
If the valuetype/eventtype represented by the target TypeCode has a concrete base valuetype/eventtype, the concrete_base_type
operation returns a TypeCode for the concrete base, otherwise it returns a nil TypeCode reference.
The length operation can be invoked on string, wide string, sequence, and array TypeCodes. For strings and sequences, it returns
the bound, with zero indicating an unbounded string or sequence. For arrays, it returns the number of elements in the array.
For wide strings, it returns the bound, or zero for unbounded wide strings.