6
For an ORB to correctly process requests, it must have access to the definitions of the objects it is handling. Object definitions can be made available to an ORB in one of two forms:
1. By incorporating the information procedurally into stub routines (e.g., as code that maps C language subroutines into communication protocols).
2. As objects accessed through the dynamically accessible Interface Repository (i.e., as "interface objects" accessed through OMG IDL-specified interfaces).
In particular, the ORB can use object definitions maintained in the Interface Repository to interpret and handle the values provided in a request:
6.2 Scope of an Interface Repository
Interface definitions are maintained in the Interface Repository as a set of objects that are accessible through a set of OMG IDL-specified interface definitions. An interface definition contains a description of the operations it supports, including the types of the parameters, exceptions it may raise, and context information it may use.
Meanwhile at SoftCo, someone working on a new Doc interface has given it a new repository id 456, which allows the ORBs to distinguish it from the current product Doc interface.
Using Repository IDs to establish correspondence between repositories
6.3 Implementation Dependencies
An implementation of an Interface Repository requires some form of persistent object store. Normally the kind of persistent object store used determines how interface definitions are distributed and/or replicated throughout a network domain. For example, if an Interface Repository is implemented using a filing system to provide object storage, there may be only a single copy of a set of interfaces maintained on a single machine. Alternatively, if an OODB is used to provide object storage, multiple copies of interface definitions may be maintained each of which is distributed across several machines to provide both high-availability and load-balancing. 6.3.1 Managing Interface Repositories
Interface Repositories contain the information necessary to allow programs to determine and manipulate the type information at runtime. Programs may attempt to access the interface repository at any time by using the get_interface operation on the object reference. Once information has been installed in the repository, programs, stubs, and objects may depend on it. Updates to the repository must be done with care to avoid disrupting the environment. A variety of techniques are available to help do so. 6.4 Basics of the Interface Repository Interface
This section introduces some basic ideas that are important to understanding the Interface Repository. Topics addressed in this section are:
Scoped names uniquely identify modules, interfaces, constant, typedefs, exceptions, attributes, and operations in an Interface Repository.
Repository identifiers globally identify modules, interfaces, constants, typedefs, exceptions, attributes, and operations. They can be used to synchronize definitions across multiple ORBs and Repositories.
6.4.3 Interface Objects
Each interface managed in an Interface Repository is maintained as a collection of interface objects:
The CORBA specification defines a minimal set of operations for interface objects. Additional operations that an implementation of the Interface Repository may provide could include operations that provide for the versioning of interfaces and for the reverse compilation of specifications (i.e., the generation of a file containing an object's OMG IDL specification).
6.4.4 Structure and Navigation of Interface Objects
The definitions in the Interface Repository are structured as a set of objects. The objects are structured the same way definitions are structured-some objects (definitions) "contain" other objects.
FIGURE 13. Interface Repository Object Containment
6.5 Interface Repository Interfaces
Several abstract interfaces are used as base interfaces for other objects in the IR. 6.5.1 Supporting Type Definitions
Several types are used throughout the IR interface definitions. typedef string Identifier;
typedef string ScopedName;
typedef string RepositoryId;
enum DefinitionKind {
dk_none, dk_all, dk_Attribute, dk_Constant, dk_Exception, dk_Interface,
dk_Module, dk_Operation, dk_Typedef,
dk_Alias, dk_Struct, dk_Union, dk_Enum,
dk_Primitive, dk_String, dk_Sequence, dk_Array,
dk_Repository
};
};
A RepositoryId is an identifier used to uniquely and globally identify a module, interface, constant, typedef, exception, attribute or operation. As RepositoryIds are defined as strings, they can be manipulated (e.g., copied and compared) using a language binding's string manipulation routines.
6.5.2 IRObject
The IRObject interface represents the most generic interface from which all other Interface Repository interfaces are derived, even the Repository itself. interface IRObject {
// read interface
readonly attribute DefinitionKind def_kind;
// write interface
void destroy ();
};
}; Read Interface
The def_kind attribute identifies the type of the definition. Write Interface
The destroy operation causes the object to cease to exist. If the object is a Container, destroy is applied to all its contents. If the object contains an IDLType attribute for an anonymous type, that IDLType is destroyed. If the object is currently contained in some other object, it is removed. Invoking destroy on a Repository or on a PrimitiveDef is an error. Implementations may very in their handling of references to an object the is being destroyed, but the Repository should not be left in an incoherent state. 6.5.3 Contained
The Contained interface is inherited by all Interface Repository interfaces that are contained by other IR objects. All objects within the Interface Repository, except the root object (Repository) and definitions of anonymous (ArrayDef, StringDef, and SequenceDef), and primitive types are contained by other objects. typedef string VersionSpec;
interface Contained : IRObject {
// read/write interface
attribute RepositoryId id;
attribute Identifier name;
attribute VersionSpec version;
// read interface
readonly attribute Container defined_in;
readonly attribute ScopedName absolute_name;
readonly attribute Repository containing_repository;
struct Description {
DefinitionKind kind;
any value;
};
Description describe ();
// write interface void move (
in Container new_container,
in Identifier new_name,
in VersionSpec new_version
);
};
}; Read Interface
An object that is contained by another object has an id attribute that identifies it globally, and a name attribute that identifies it uniquely within the enclosing Container object. It also has a version attribute that distinguishes it from other versioned objects with the same name. IRs are not required to support simultaneous containment of multiple versions of the same named object. Supporting multiple versions most likely requires mechanism and policy not specified in this document. Write Interface
Setting the id attribute changes the global identity of this definition. An error is returned if an object with the specified id attribute already exists within this object's Repository.
The defined_in and absolute_name attributes are updated to reflect the new container and name. If this object is also a Container, the absolute_name attributes of any objects it contains are also updated.
module CORBA {
typedef sequence <Contained> ContainedSeq;
interface Container : IRObject {
// read interface
Contained lookup ( in ScopedName search_name);
ContainedSeq contents (
in DefinitionKind limit_type,
in boolean exclude_inherited
);
ContainedSeq lookup_name (
in Identifier search_name,
in long levels_to_search,
in DefinitionKind limit_type,
in boolean exclude_inherited
);
struct Description {
Contained contained_object;
DefinitionKind kind;
any value;
};
typedef sequence<Description> DescriptionSeq;
DescriptionSeq describe_contents (
in DefinitionKind limit_type,
in boolean exclude_inherited,
in long max_returned_objs
);
// write interface
ModuleDef create_module (
in RepositoryId id,
in Identifier name,
in VersionSpec version
);
ConstantDef create_constant (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType type,
in any value
);
StructDef create_struct (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in StructMemberSeq members
);
UnionDef create_union (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType discriminator_type,
in UnionMemberSeq members
);
EnumDef create_enum (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in EnumMemberSeq members
);
AliasDef create_alias (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType original_type
);
InterfaceDef create_interface (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in InterfaceDefSeq base_interfaces
);
};};
The contents operation returns the list of objects directly contained by or inherited into the object. The operation is used to navigate through the hierarchy of objects. Starting with the Repository object, a client uses this operation to list all of the objects contained by the Repository, all of the objects contained by the modules within the Repository, and then all of the interfaces within a specific module, and so on.
limit_type If limit_type is set to dk_all, objects of all interface types are returned. For example, if this is an InterfaceDef, the attribute, operation, and exception objects are all returned. If limit_type is set to a specific interface, only objects of that interface type are returned. For example, only attribute objects are returned if limit_type is set to dk_Attribute.
exclude_inherited If set to TRUE, inherited objects (if there are any) are not returned. If set to FALSE, all contained objects-whether contained due to inheritance or because they were defined within the object-are returned.
The lookup_name operation is used to locate an object by name within a particular object or within the objects contained by that object.
search_name Specifies which name is to be searched for.
levels_to_search Controls whether the lookup is constrained to the object the operation is invoked on or whether it should search through objects contained by the object as well.
Setting levels_to_search to -1 searches the current object and all contained objects. Setting levels_to_search to 1 searches only the current object.
limit_type If limit_type is set to dk_all, objects of all interface types are returned (e.g., attributes, operations, and exceptions are all returned). If limit_type is set to a specific interface, only objects of that interface type are returned. For example, only attribute objects are returned if limit_type is set to dk_Attribute.
exclude_inherited If set to TRUE, inherited objects (if there are any) are not returned. If set to FALSE, all contained objects (whether contained due to inheritance or because they were defined within the object) are returned.
The describe_contents operation combines the contents operation and the describe operation. For each object returned by the contents operation, the description of the object is returned (i.e., the object's describe operation is invoked and the results returned).
max_returned_objs Limits the number of objects that can be returned in an invocation of the call to the number provided. Setting the parameter to -1 means return all contained objects.
The create_<type> operations all take id and name parameters which are used to initialize the identity of the created definition. An error is returned if an object with the specified id already exists within this object's Repository, or, assuming multiple versions are not supported, if an object with the specified name already exists within this Container.
The create_module operation returns a new empty ModuleDef. Definitions can be added using Container::create_<type> operations on the new module, or by using the Contained::move operation.
The create_constant operation returns a new ConstantDef with the specified type and value.
The create_struct operation returns a new StructDef with the specified members. The type member of the StructMember structures is ignored, and should be set to TC_void. See "StructDef" on page 6-19 for more information.
The create_union operation returns a new UnionDef with the specified discriminator_type and members. The type member of the UnionMember structures is ignored, and should be set to TC_void. See "UnionDef" on page 6-19 for more information.
The create_enum operation returns a new EnumDef with the specified members. See "EnumDef" on page 6-20 for more information.
The create_alias operation returns a new AliasDef with the specified original_type.
6.5.5 IDLType
The IDLType interface is an abstract interface inherited by all IR objects that represent OMG IDL types. It provides access to the TypeCode describing the type, and is used in defining other interfaces wherever definitions of IDL types must be referenced. interface IDLType : IRObject {
readonly attribute TypeCode type;
};
}; 6.5.6 Repository
Repository is an interface that provides global access to the Interface Repository. The Repository object can contain constants, typedefs, exceptions, interfaces, and modules. As it inherits from Container, it can be used to look up any definition (whether globally defined or defined within a module or interface) either by name or by id. interface Repository : Container {
// read interface
Contained lookup_id (in RepositoryId search_id);
PrimitiveDef get_primitive (in PrimitiveKind kind);
// write interface
StringDef create_string (in unsigned long bound);
SequenceDef create_sequence (
in unsigned long bound,
in IDLType element_type
);
ArrayDef create_array (
in unsigned long length,
in IDLType element_type
);
};
}; Read Interface
The lookup_id operation is used to lookup an object in a Repository given its RepositoryId. If the Repository does not contain a definition for search_id, a nil object reference is returned. Write Interface
The three create_<type> operations create new objects defining anonymous types. As these interfaces are not derived from Contained, it is the caller's responsibility to invoke destroy on the returned object if it is not successfully used in creating a definition that is derived from Contained. Each anonymous type definition must be used in defining exactly one other object. 6.5.7 ModuleDef
A ModuleDef can contain constants, typedefs, exceptions, interfaces and other module objects. interface ModuleDef : Container, Contained {
};
struct ModuleDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
};
}; 6.5.8 ConstantDef Interface
A ConstantDef object defines a named constant. interface ConstantDef : Contained {
readonly attribute TypeCode type;
attribute IDLType type_def;
attribute any value;
};
struct ConstantDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode type;
any value;
};
}; Read Interface
The type attribute specifies the TypeCode describing the type of the constant. The type of a constant must be one of the simple types (long, short, float, char, string, octet, etc.). The type_def attribute identifies the definition of the type of the constant. Write Interface
Setting the type_def attribute also updates the type attribute. 6.5.9 TypedefDef Interface
TypedefDef is an abstract interface used as a base interface for all named non-object types (structures, unions, enumerations, and aliases). The TypedefDef interface is not inherited by the definition objects for primitive or anonymous types. interface TypedefDef : Contained, IDLType {
};
struct TypeDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode type;
};
}; 6.5.10 StructDef
A StructDef represents an OMG IDL structure definition. struct StructMember {
Identifier name;
TypeCode type;
IDLType type_def;
};
typedef sequence <StructMember> StructMemberSeq;
interface StructDef : TypedefDef {
attribute StructMemberSeq members;
};
}; Read Interface
The members attribute contains a description of each structure member. Write Interface
Setting the members attribute also updates the type attribute. When setting the members attribute, the type member of the StructMember structure is ignored and should be set to TC_void. 6.5.11 UnionDef
A UnionDef represents an OMG IDL union definition. struct UnionMember {
Identifier name;
any label;
TypeCode type;
IDLType type_def;
};
typedef sequence <UnionMember> UnionMemberSeq;
interface UnionDef : TypedefDef {
readonly attribute TypeCode discriminator_type;
attribute IDLType discriminator_type_def;
attribute UnionMemberSeq members;
};
}; Read Interface
The discriminator_type and discriminator_type_def attributes describe and identify the union's discriminator type. Write Interface
Setting the discriminator_type_def attribute also updates the discriminator_type attribute and setting the discriminator_type_def or members attribute also updates the type attribute. 6.5.12 EnumDef
An EnumDef represents an OMG IDL enumeration definition. typedef sequence <Identifier> EnumMemberSeq;
interface EnumDef : TypedefDef {
attribute EnumMemberSeq members;
};
}; Read Interface
The members attribute contains a distinct name for each possible value of the enumeration. Write Interface
Setting the members attribute also updates the type attribute. 6.5.13 AliasDef
An AliasDef represents an OMG IDL typedef that aliases another definition. interface AliasDef : TypedefDef {
attribute IDLType original_type_def;
};
}; 6.5.14 Read Interface
The original_type_def attribute identifies the type being aliased. Write Interface
Setting the original_type_def attribute also updates the type attribute. 6.5.15 PrimitiveDef
A PrimitiveDef represents one of the IDL primitive types. As primitive types are unnamed, this interface is not derived from TypedefDef or Contained. enum PrimitiveKind {
pk_null, pk_void, pk_short, pk_long, pk_ushort, pk_ulong,
pk_float, pk_double, pk_boolean, pk_char, pk_octet,
pk_any, pk_TypeCode, pk_Principal, pk_string, pk_objref
};
interface PrimitiveDef: IDLType {
readonly attribute PrimitiveKind kind;
};
}; 6.5.16 StringDef
A StringDef represents an IDL bounded string type. The unbounded string type is represented as a PrimitiveDef. As string types are anonymous, this interface is not derived from TypedefDef or Contained. interface StringDef : IDLType {
attribute unsigned long bound;
};
}; 6.5.17 SequenceDef
A SequenceDef represents an IDL sequence type. As sequence types are anonymous, this interface is not derived from TypedefDef or Contained. interface SequenceDef : IDLType {
attribute unsigned long bound;
readonly attribute TypeCode element_type;
attribute IDLType element_type_def;
};
}; Read Interface
The bound attribute specifies the maximum number of elements in the sequence. A bound of zero indicates an unbounded sequence. Write Interface
Setting the element_type_def attribute also updates the element_type attribute. 6.5.18 ArrayDef
An ArrayDef represents an IDL array type. As array types are anonymous, this interface is not derived from TypedefDef or Contained. interface ArrayDef : IDLType {
attribute unsigned long length;
readonly attribute TypeCode element_type;
attribute IDLType element_type_def;
};
}; Read Interface
The length attribute specifies the number of elements in the array. Write Interface
Setting the element_type_def attribute also updates the element_type attribute. 6.5.19 ExceptionDef
An ExceptionDef represents an exception definition. interface ExceptionDef : Contained {
readonly attribute TypeCode type; attribute StructMemberSeq members;
};
struct ExceptionDescription { Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode type;
};
}; Read Interface
The type attribute is a tk_except TypeCode describing the exception. Write Interface
Setting the members attribute also updates the type attribute. When setting the members attribute, the type member of the StructMember structure is ignored and should be set to TC_void. 6.5.20 AttributeDef
An AttributeDef represents the information that defines an attribute of an interface. enum AttributeMode {ATTR_NORMAL, ATTR_READONLY};
interface AttributeDef : Contained {
readonly attribute TypeCode type;
attribute IDLType type_def;
attribute AttributeMode mode;
};
struct AttributeDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode type;
AttributeMode mode;
};
}; Read Interface
The type attribute provides the TypeCode describing the type of this attribute. The type_def attribute identifies the object defining the type of this attribute. Write Interface
Setting the type_def attribute also updates the type attribute. 6.5.21 OperationDef
An OperationDef represents the information needed to define an operation of an interface. enum OperationMode {OP_NORMAL, OP_ONEWAY};
enum ParameterMode {PARAM_IN, PARAM_OUT, PARAM_INOUT};
struct ParameterDescription {
Identifier name;
TypeCode type;
IDLType type_def;
ParameterMode mode;
};
typedef sequence <ParameterDescription> ParDescriptionSeq;
typedef Identifier ContextIdentifier;
typedef sequence <ContextIdentifier> ContextIdSeq;
typedef sequence <ExceptionDef> ExceptionDefSeq;
typedef sequence <ExceptionDescription> ExcDescriptionSeq;
interface OperationDef : Contained {
readonly attribute TypeCode result;
attribute IDLType result_def;
attribute ParDescriptionSeq params;
attribute OperationMode mode;
attribute ContextIdSeq contexts;
attribute ExceptionDefSeq exceptions;
};
struct OperationDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode result;
OperationMode mode;
ContextIdSeq contexts;
ParDescriptionSeq parameters;
ExcDescriptionSeq exceptions;
};
}; Read Interface
The result attribute is a TypeCode describing the type of the value returned by the operation. The result_def attribute identifies the definition of the returned type. Write Interface
Setting the result_def attribute also updates the result attribute. 6.5.22 InterfaceDef
An InterfaceDef object represents an interface definition. It can contain constants, typedefs, exceptions, operations, and attributes. interface InterfaceDef;
typedef sequence <InterfaceDef> InterfaceDefSeq;
typedef sequence <RepositoryId> RepositoryIdSeq;
typedef sequence <OperationDescription> OpDescriptionSeq;
typedef sequence <AttributeDescription> AttrDescriptionSeq;
interface InterfaceDef : Container, Contained, IDLType {
// read/write interface
attribute InterfaceDefSeq base_interfaces;
// read interface
boolean is_a (in RepositoryId interface_id);
struct FullInterfaceDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
OpDescriptionSeq operations;
AttrDescriptionSeq attributes;
RepositoryIdSeq base_interfaces;
TypeCode type;
};
FullInterfaceDescription describe_interface();
// write interface
AttributeDef create_attribute (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType type,
in AttributeMode mode
);
OperationDef create_operation (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType result,
in OperationMode mode,
in ParDescriptionSeq params,
in ExceptionDefSeq exceptions,
in ContextIdSeq contexts
);
};
struct InterfaceDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
RepositoryIdSeq base_interfaces;
};
}; Read Interface
The base_interfaces attribute lists all the interfaces from which this interface inherits. The is_a operation returns TRUE if the interface on which it is invoked either is identical to or inherits, directly or indirectly, from the interface identified by its interface_id parameter. Otherwise it returns FALSE. Write Interface
Setting the base_interfaces attribute returns an error if the name attribute of any object contained by this InterfaceDef conflicts with the name attribute of any object contained by any of the specified base InterfaceDefs. 6.6 RepositoryIds
RepositoryIds are values that can be used to establish the identity of information in the repository. A RepositoryId is represented as a string, allowing programs to store, copy, and compare them without regard to the structure of the value. It does not matter what format is used for any particular RepositoryId. However, conventions are used to manage the name space created by these IDs. 6.6.1 OMG IDL Format
The OMG IDL format for RepositoryIds primarily uses OMG IDL scoped names to distinguish between definitions. It also includes an optional unique prefix, and major and minor version numbers. 6.6.2 DCE UUID Format
DCE UUID format RepositoryIds start with the characters "DCE:" and are followed by the printable form of the UUID, a colon, and a decimal minor version number, for example: "DCE:700dc518-0110-11ce-ac8f-0800090b5d3e:1". 6.6.3 LOCAL Format
Local format RepositoryIds start with the characters "LOCAL:" and are followed by an arbitrary string. Local format IDs are not intended for use outside a particular repository, and thus do not need to conform to any particular convention. Local IDs that are just consecutive integers might be used within a development environment to have a very cheap way to manufacture the IDs while avoiding conflicts with well-known interfaces. 6.6.4 Pragma Directives for RepositoryId
Three pragma directives (id, prefix, and version), are specified accommodate arbitrary RepositoryId formats and still support the OMG IDL RepositoryId format with minimal annotation. The pragma directives can be used with the OMG IDL, DCE UUID, and LOCAL formats. An IDL compiler must either interpret these annotations as specified, or ignore them completely. The ID Pragma
An OMG IDL pragma of the format The Prefix Pragma
An OMG IDL pragma of the format The Version Pragma
An OMG IDL pragma of the format Generation of OMG IDL - Format IDs
A definition is globally identified by an OMG IDL - format RepositoryId if no ID pragma is encountered for it. typedef long T1;
typedef long T2;
#pragma ID T2 "DCE:d62207a2-011e-11ce-88b4-0800090b5d3e:3"
};
#pragma prefix "P1"
module M2 {
module M3 {
#pragma prefix "P2"
typedef long T3;
};
typedef long T4;
#pragma version T4 2.4
}; #pragma prefix "P1/M2"
module M3 {
#pragma prefix "P2"
typedef long T3;
};
typedef long T4;
#pragma version T4 2.4
}; For More Information
Section 6.8, "OMG IDL for Interface Repository," on page 6-41 shows the OMG IDL specification of the IR, including the #pragma directive; Section 3.3, "Preprocessing," on page 3-8 contain additional, general information on the pragma directive.
6.7 TypeCodes
TypeCodes are values that represent invocation argument types and attribute types. They can be obtained from the Interface Repository or from IDL compilers. 6.7.1 The TypeCode Interface
The PIDL interface for TypeCodes is 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
};
interface TypeCode {
exception Bounds {};
exception BadKind {};
// for all TypeCode kinds
boolean equal (in TypeCode tc);
TCKind kind ();
// for tk_objref, tk_struct, tk_union, tk_enum, tk_alias, and tk_except
RepositoryId id () raises (BadKind);
// for tk_objref, tk_struct, tk_union, tk_enum, tk_alias, and tk_except
Identifier name () raises (BadKind);
// for tk_struct, tk_union, tk_enum, and tk_except
unsigned long member_count () raises (BadKind);
Identifier member_name (in unsigned long index) raises (BadKind, Bounds);
// for tk_struct, tk_union, and tk_except
TypeCode member_type (in unsigned long index) raises (BadKind, Bounds);
// for tk_union
any member_label (in unsigned long index) raises (BadKind, Bounds);
TypeCode discriminator_type () raises (BadKind);
long default_index () raises (BadKind);
// for tk_string, tk_sequence, and tk_array
unsigned long length () raises (BadKind);
// for tk_sequence, tk_array, and tk_alias
TypeCode content_type () raises (BadKind);
// deprecated interface
long param_count ();
any parameter (in long index) raises (Bounds);
};
};
The tk_objref TypeCode represents an interface type. Its parameter is the RepositoryId of that interface.
6.7.2 TypeCode Constants
If "typedef ... FOO;" is an IDL type declaration, the IDL compiler will (if asked) produce a declaration of a TypeCode constant named TC_FOO for the C language mapping. In the case of an unnamed, bounded string type used directly in an operation or attribute declaration, a TypeCode constant named TC_string_n, where n is the bound of the string is produced. (For example, "string<4> op1();" produces the constant "TC_string_4".) These constants can be used with the dynamic invocation interface, and any other routines that require TypeCodes. The predefined TypeCode constants, named according to the C language mapping, are:
TC_void
TC_short
TC_long
TC_ushort
TC_ulong
TC_float
TC_double
TC_boolean
TC_char
TC_octet
TC_any
TC_TypeCode
TC_Principal
TC_Object = tk_objref { Object }
TC_string = tk_string { 0 } // unbounded
TC_CORBA_NamedValue = tk_struct { ... }
TC_CORBA_InterfaceDescription = tk_struct { ... }
TC_CORBA_OperationDescription = tk_struct { ... }
TC_CORBA_AttributeDescription = tk_struct { ... }
TC_CORBA_ParameterDescription = tk_struct { ... }
TC_CORBA_ModuleDescription = tk_struct { ... }
TC_CORBA_ConstantDescription = tk_struct { ... }
TC_CORBA_ExceptionDescription = tk_struct { ... }
TC_CORBA_TypeDescription = tk_struct { ... }
TC_CORBA_InterfaceDef_FullInterfaceDescription = tk_struct { ... } 6.7.3 Creating TypeCodes
When creating type definition objects in an Interface Repository, types are specified in terms of object references, and the TypeCodes describing them are generated automatically. interface ORB {
// other operations ...
TypeCode create_struct_tc (
in RepositoryId id,
in Identifier name,
in StructMemberSeq members
);
TypeCode create_union_tc (
in RepositoryId id,
in Identifier name,
in TypeCode discriminator_type,
in UnionMemberSeq members
);
TypeCode create_enum_tc (
in RepositoryId id,
in Identifier name,
in EnumMemberSeq members
);
TypeCode create_alias_tc (
in RepositoryId id,
in Identifier name,
in TypeCode original_type
);
TypeCode create_exception_tc (
in RepositoryId id,
in Identifier name,
in StructMemberSeq members
);
TypeCode create_interface_tc (
in RepositoryId id,
in Identifier name
);
TypeCode create_string_tc (
in unsigned long bound
);
TypeCode create_sequence_tc (
in unsigned long bound,
in TypeCode element_type
);
TypeCode create_recursive_sequence_tc (
in unsigned long bound,
in unsigned long offset
);
TypeCode create_array_tc (
in unsigned long length,
in TypeCode element_type
);
};
};
struct foo {
long value;
sequence <foo> chain;
};
Operations to create primitive TypeCodes are not needed, since TypeCode constants for these are available. 6.8 OMG IDL for Interface Repository
This section contains the complete OMG IDL specification for the Interface Repository.#pragma prefix "omg.org"
module CORBA { typedef string Identifier;
typedef string ScopedName;
typedef string RepositoryId;
enum DefinitionKind {
dk_none, dk_all,
dk_Attribute, dk_Constant, dk_Exception, dk_Interface,
dk_Module, dk_Operation, dk_Typedef,
dk_Alias, dk_Struct, dk_Union, dk_Enum,
dk_Primitive, dk_String, dk_Sequence, dk_Array,
dk_Repository
};
interface IRObject {
// read interface
readonly attribute DefinitionKind def_kind;
// write interface
void destroy ();
};
typedef string VersionSpec;
interface Contained;
interface Repository;
interface Container;
interface Contained : IRObject {
// read/write interface
attribute RepositoryId id;
attribute Identifier name;
attribute VersionSpec version;
// read interface
readonly attribute Container defined_in;
readonly attribute ScopedName absolute_name;
readonly attribute Repository containing_repository;
struct Description {
DefinitionKind kind;
any value;
};
Description describe ();
// write interface
void move (
in Container new_container,
in Identifier new_name,
in VersionSpec new_version
);
};
interface ModuleDef;
interface ConstantDef;
interface IDLType;
interface StructDef;
interface UnionDef;
interface EnumDef;
interface AliasDef;
interface InterfaceDef;
typedef sequence <InterfaceDef> InterfaceDefSeq;
typedef sequence <Contained> ContainedSeq;
struct StructMember {
Identifier name;
TypeCode type;
IDLType type_def;
};
typedef sequence <StructMember> StructMemberSeq;
struct UnionMember {
Identifier name;
any label;
TypeCode type;
IDLType type_def;
};
typedef sequence <UnionMember> UnionMemberSeq;
typedef sequence <Identifier> EnumMemberSeq;
interface Container : IRObject {
// read interface
Contained lookup ( in ScopedName search_name);
ContainedSeq contents (
in DefinitionKind limit_type,
in boolean exclude_inherited
);
ContainedSeq lookup_name (
in Identifier search_name,
in long levels_to_search,
in DefinitionKind limit_type,
in boolean exclude_inherited
);
struct Description {
Contained contained_object;
DefinitionKind kind;
any value;
};
typedef sequence<Description> DescriptionSeq;
DescriptionSeq describe_contents (
in DefinitionKind limit_type,
in boolean exclude_inherited,
in long max_returned_objs
);
// write interface
ModuleDef create_module (
in RepositoryId id,
in Identifier name,
in VersionSpec version
);
ConstantDef create_constant (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType type,
in any value
);
StructDef create_struct (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in StructMemberSeq members
);
UnionDef create_union (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType discriminator_type,
in UnionMemberSeq members
);
EnumDef create_enum (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in EnumMemberSeq members
);
AliasDef create_alias (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType original_type
);
InterfaceDef create_interface (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in InterfaceDefSeq base_interfaces
);
};
interface IDLType : IRObject {
readonly attribute TypeCode type;
};
interface PrimitiveDef;
interface StringDef;
interface SequenceDef;
interface ArrayDef;
enum PrimitiveKind {
pk_null, pk_void, pk_short, pk_long, pk_ushort, pk_ulong,
pk_float, pk_double, pk_boolean, pk_char, pk_octet,
pk_any, pk_TypeCode, pk_Principal, pk_string, pk_objref
};
interface Repository : Container {
// read interface
Contained lookup_id (in RepositoryId search_id);
PrimitiveDef get_primitive (in PrimitiveKind kind);
// write interface
StringDef create_string (in unsigned long bound);
SequenceDef create_sequence (
in unsigned long bound,
in IDLType element_type
);
ArrayDef create_array (
in unsigned long length,
in IDLType element_type
);
};
interface ModuleDef : Container, Contained {
};
struct ModuleDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
};
interface ConstantDef : Contained {
readonly attribute TypeCode type;
attribute IDLType type_def;
attribute any value;
};
struct ConstantDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode type;
any value;
};
interface TypedefDef : Contained, IDLType {
};
struct TypeDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode type;
};
interface StructDef : TypedefDef {
attribute StructMemberSeq members;
};
interface UnionDef : TypedefDef {
readonly attribute TypeCode discriminator_type;
attribute IDLType discriminator_type_def;
attribute UnionMemberSeq members;
};
interface EnumDef : TypedefDef {
attribute EnumMemberSeq members;
};
interface AliasDef : TypedefDef {
attribute IDLType original_type_def;
};
interface PrimitiveDef: IDLType {
readonly attribute PrimitiveKind kind;
};
interface StringDef : IDLType {
attribute unsigned long bound;
};
interface SequenceDef : IDLType {
attribute unsigned long bound;
readonly attribute TypeCode element_type;
attribute IDLType element_type_def;
};
interface ArrayDef : IDLType {
attribute unsigned long length;
readonly attribute TypeCode element_type;
attribute IDLType element_type_def;
};
interface ExceptionDef : Contained {
readonly attribute TypeCode type;
attribute StructMemberSeq members;
};
struct ExceptionDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode type;
};
enum AttributeMode {ATTR_NORMAL, ATTR_READONLY};
interface AttributeDef : Contained {
readonly attribute TypeCode type;
attribute IDLType type_def;
attribute AttributeMode mode;
};
struct AttributeDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode type;
AttributeMode mode;
};
enum OperationMode {OP_NORMAL, OP_ONEWAY};
enum ParameterMode {PARAM_IN, PARAM_OUT, PARAM_INOUT};
struct ParameterDescription {
Identifier name;
TypeCode type;
IDLType type_def;
ParameterMode mode;
};
typedef sequence <ParameterDescription> ParDescriptionSeq;
typedef Identifier ContextIdentifier;
typedef sequence <ContextIdentifier> ContextIdSeq;
typedef sequence <ExceptionDef> ExceptionDefSeq;
typedef sequence <ExceptionDescription> ExcDescriptionSeq;
interface OperationDef : Contained {
readonly attribute TypeCode result;
attribute IDLType result_def;
attribute ParDescriptionSeq params;
attribute OperationMode mode;
attribute ContextIdSeq contexts;
attribute ExceptionDefSeq exceptions;
};
struct OperationDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
TypeCode result;
OperationMode mode;
ContextIdSeq contexts;
ParDescriptionSeq parameters;
ExcDescriptionSeq exceptions;
};
typedef sequence <RepositoryId> RepositoryIdSeq;
typedef sequence <OperationDescription> OpDescriptionSeq;
typedef sequence <AttributeDescription> AttrDescriptionSeq;
interface InterfaceDef : Container, Contained, IDLType {
// read/write interface
attribute InterfaceDefSeq base_interfaces;
// read interface
boolean is_a (in RepositoryId interface_id);
struct FullInterfaceDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
OpDescriptionSeq operations;
AttrDescriptionSeq attributes;
RepositoryIdSeq base_interfaces;
TypeCode type;
};
FullInterfaceDescription describe_interface();
// write interface
AttributeDef create_attribute (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType type,
in AttributeMode mode
);
OperationDef create_operation (
in RepositoryId id,
in Identifier name,
in VersionSpec version,
in IDLType result,
in OperationMode mode,
in ParDescriptionSeq params,
in ExceptionDefSeq exceptions,
in ContextIdSeq contexts
);
};
struct InterfaceDescription {
Identifier name;
RepositoryId id;
RepositoryId defined_in;
VersionSpec version;
RepositoryIdSeq base_interfaces;
};
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
};
interface TypeCode { // PIDL
exception Bounds {};
exception BadKind {};
// for all TypeCode kinds
boolean equal (in TypeCode tc);
TCKind kind ();
// for tk_objref, tk_struct, tk_union, tk_enum, tk_alias, and tk_except
RepositoryId id () raises (BadKind);
// for tk_objref, tk_struct, tk_union, tk_enum, tk_alias, and tk_except
Identifier name () raises (BadKind);
// for tk_struct, tk_union, tk_enum, and tk_except
unsigned long member_count () raises (BadKind);
Identifier member_name (in unsigned long index) raises (BadKind, Bounds);
// for tk_struct, tk_union, and tk_except
TypeCode member_type (in unsigned long index) raises (BadKind, Bounds);
// for tk_union
any member_label (in unsigned long index) raises (BadKind, Bounds);
TypeCode discriminator_type () raises (BadKind);
long default_index () raises (BadKind);
// for tk_string, tk_sequence, and tk_array
unsigned long length () raises (BadKind);
// for tk_sequence, tk_array, and tk_alias
TypeCode content_type () raises (BadKind);
// deprecated interface
long param_count ();
any parameter (in long index) raises (Bounds);
};
interface ORB {
// other operations ...
TypeCode create_struct_tc (
in RepositoryId id,
in Identifier name,
in StructMemberSeq members
);
TypeCode create_union_tc (
in RepositoryId id,
in Identifier name,
in TypeCode discriminator_type,
in UnionMemberSeq members
);
TypeCode create_enum_tc (
in RepositoryId id,
in Identifier name,
in EnumMemberSeq members
);
TypeCode create_alias_tc (
in RepositoryId id,
in Identifier name,
in TypeCode original_type
);
TypeCode create_exception_tc (
in RepositoryId id,
in Identifier name,
in StructMemberSeq members
);
TypeCode create_interface_tc (
in RepositoryId id,
in Identifier name
);
TypeCode create_string_tc (
in unsigned long bound
);
TypeCode create_sequence_tc (
in unsigned long bound,
in TypeCode element_type
);
TypeCode create_recursive_sequence_tc (
in unsigned long bound,
in unsigned long offset
);
TypeCode create_array_tc (
in unsigned long length,
in TypeCode element_type
);
};
};