![]() |
Overview The create_constant operation creates a new ConstantDef object. Original interface CORBA module: Container Interface Exceptions CORBA::SystemException
Intended Usage
The create_constant operation creates a new ConstantDef object with the specified type and value. A representation of the new ConstantDef object is created in the Interface Repository persistent database and a pointer to the memory representation of the ContstantDef object is returned to the caller.
IDL Syntax
ConstantDef create_constant (in RepositoryId Id, in Identifier name, in VersionSpec version, in IDLType type, in any value);
Input parameters
- value
- The value parameter is an CORBA::Any reference. The Any contains the value of the constant.
- name
- The name that is associated with this ConstantDef object in the Interface Repository.
- type
- The type parameter is a CORBA::IDLType * that specifies the type of the ConstantDef. The type should be a CORBA::PrimitiveDef object of a simple type (pk_short, pk_long, pk_ushort, pk_ulong, pk_float, pk_double, pk_boolean, pk_char, pk_wchar, pk_string, pk_wstring, or pk_octet).
- id
- The id represents the CORBA::RepositoryId that will uniquely identify this ConstantDef within the Interface Repository.
- version
- The version number that will be associated with this ConstantDef object in the Interface Repository.
Return values
- ConstantDef_ptr
- A pointer to the created ConstantDef object is returned to the caller. The memory associated with this object can later be released by invoking CORBA::release.
Example
// C++ // repository_ptr and module_one has already been initialized . . . CORBA::Repository * repository_ptr; CORBA::ModuleDef * module_one; CORBA::RepositoryId constants_rep_id; CORBA::Identifier constants_name; CORBA::VersionSpec version; CORBA::ConstantDef * constant_def_one; CORBA::Any constants_value; CORBA::PrimitiveDef * primitive_long; // establish the id, name, and version values for the constant constants_rep_id = CORBA::string_dup ("unique RepositoryID for my constant"); constants_name = CORBA::string_dup ("constant_of_2001"); version = CORBA::string_dup ("1.0"); // establish the Any with a 'value' of 2001 constants_value <<= (CORBA::Long) 2001; // create a PrimitiveDef that represents a CORBA::Long data type primitive_long = repository_ptr-> get_primitive (CORBA::pk_long); // create the new constant that will be contained in module_one constant_def_one = module_one-> create_constant (constants_rep_id, constants_name, version, primitive_long, constants_value);