![]() |
Overview The create_struct operation creates a new structure definition (StructDef) in the Interface Repository. Original interface CORBA module: Container Interface Exceptions CORBA::SystemException
Intended Usage
The create_struct operation creates a new structure definition in the Interface Repository persistent database, and returns a pointer to a new StructDef object associated with the struct definition.
IDL Syntax
StructDef create_struct (in RepositoryId id, in Identifier name, in VersionSpec version, in StructMemberSeq members);
Input parameters
- name
- The name that will be associated with this StructDef object in the Interface Repository.
- id
- The id represents the CORBA::RepositoryId that will uniquely identify this StructDef within the Interface Repository.
- members
This is a reference to a CORBA::StructMemberSeq that provides the list of the elements will comprise the new structure (StructDef). The length of the CORBA::StructMemberSeq must be greater than zero.
Each CORBA::StructMember within the CORBA::StructMemberSeq has 3 fields. The name field identifies the name of the StructMember. The type field of the StructMember is ignored by create_struct, and should be set to CORBA::_tc_void. The type_def field is a CORBA::IDLType * that represents the type definition of the StructMember.
- version
- The version number that will be associated with this StructDef object in the Interface Repository.
Return values
- StructDef_ptr
- A pointer to the created StructDef object is returned to the caller. The memory associated with this object can later be released by invoking CORBA::release.
Example
// C++ // assume 'primitive_long', 'primitive_double', // and 'repository_ptr' have already been instantiated CORBA::PrimitiveDef * primitive_double; CORBA::PrimitiveDef * primitive_long; CORBA::Repository * repository_ptr; // establish the id, name, and version values for the structure CORBA::RepositoryId rep_id; CORBA::Identifier name; CORBA::VersionSpec version; rep_id = CORBA::string_dup ("unique RepositoryId for my structure"); name = CORBA::string_dup ("structure_new"); version = CORBA::string_dup ("1.0"); /// instantiate a StructMemberSeq and set the length to 2 CORBA::StructMemberSeq struct_members; struct_members.length(2); // establish the StructMemberSeq to represent a structure with two // elements: a CORBA::Double called 'x', and a CORBA::Long called 'y'. struct_members[0].name = CORBA::string_dup ("x"); struct_members[0].type_def = CORBA::IDLType::_duplicate (primitive_double); struct_members[1].name = CORBA::string_dup ("y"); struct_members[1].type_def = CORBA::IDLType::_duplicate (primitive_long); // create the new structure . . . CORBA::StructDef * new_struct; new_struct = repository_ptr-> create_struct (rep_id, name, version, struct_members);