TypeCodeFactory Class Reference
[Type Code Support]

A singleton factory for creating, copying, and deleting data type definitions dynamically. More...

List of all members.

Public Member Functions

TypeCode create_struct_tc (String name, StructMember[] members) throws BAD_PARAM
 Constructs a TCKind.TK_STRUCT TypeCode.
TypeCode create_value_tc (String name, short type_modifier, TypeCode concrete_base, ValueMember[] members) throws BAD_PARAM
 Constructs a TCKind.TK_VALUE TypeCode.
TypeCode create_sparse_tc (String name, short type_modifier, TypeCode concrete_base) throws BAD_PARAM
 Constructs a TCKind.TK_SPARSE TypeCode.
TypeCode create_union_tc (String name, TypeCode discriminator_type, int default_index, UnionMember[] members) throws BAD_PARAM
 Constructs a TCKind.TK_UNION TypeCode.
TypeCode create_enum_tc (String name, EnumMember[] members) throws BAD_PARAM
 Constructs a TCKind.TK_ENUM TypeCode.
TypeCode create_alias_tc (String name, TypeCode original_type, boolean is_pointer) throws BAD_PARAM
 Constructs a TCKind.TK_ALIAS (typedef) TypeCode.
TypeCode create_string_tc (int bound) throws BAD_PARAM
 Constructs a TCKind.TK_STRING TypeCode.
TypeCode create_wstring_tc (int bound) throws BAD_PARAM
 Constructs a TCKind.TK_WSTRING TypeCode.
TypeCode create_sequence_tc (int bound, TypeCode element_type) throws BAD_PARAM
 Constructs a TCKind.TK_SEQUENCE TypeCode.
TypeCode create_array_tc (int[] dimensions, TypeCode element_type) throws BAD_PARAM
 Constructs a TCKind.TK_ARRAY TypeCode.
TypeCode create_array_tc (int length, TypeCode element_type) throws BAD_PARAM
 Constructs a TCKind.TK_ARRAY TypeCode for a single-dimensional array.
TypeCode clone_tc (TypeCode tc)
 Creates and returns a copy of the input TypeCode.
void delete_tc (TypeCode tc)
 Deletes the input TypeCode.
TypeCode get_primitive_tc (TCKind kind) throws BAD_PARAM
 Get the TypeCode for a primitive type (integers, floating point values, etc.) identified by the given TCKind.

Static Public Member Functions

static final TypeCodeFactory get_instance ()
 Gets the singleton instance of this class.


Detailed Description

A singleton factory for creating, copying, and deleting data type definitions dynamically.

You can access the singleton with the TypeCodeFactory.get_instance method.

If you want to publish and subscribe to data of types that are not known to you at system design time, this class will be your starting point. After creating a data type definition with this class, you will modify that definition using the TypeCode class and then register it with the Dynamic Data API.

The methods of this class fall into several categories:

Getting definitions for primitive types:
Type definitions for primitive types (e.g. integers, floating point values, etc.) are pre-defined; your application only needs to get them, not create them.

Creating definitions for strings, arrays, and sequences:
Type definitions for strings, arrays, and sequences (i.e. variables-size lists) must be created as you need them, because the type definition includes the maximum length of those containers. Creating definitions for structured types:
Structured types include structures, value types, sparse value types, and unions. Creating definitions for other types:
The type system also supports enumerations and aliases (i.e. typedefs in C and C++). Deleting type definitions:
When you're finished using a type definition, you should delete it. (Note that you only need to delete a TypeCode that you created; if you got the object from TypeCodeFactory.get_primitive_tc, you must not delete it.) Copying type definitions:
You can also create deep copies of type definitions:

Member Function Documentation

static final TypeCodeFactory get_instance (  )  [static]

Gets the singleton instance of this class.

Returns:
The TypeCodeFactory instance if no errors. Otherwise, null.

TypeCode create_struct_tc ( String  name,
StructMember[]  members 
) throws BAD_PARAM

Constructs a TCKind.TK_STRUCT TypeCode.

Parameters:
name <<in>> Name of the struct type. Cannot be null.
members <<in>> Initial members of the structure. This list may be empty (that is, Sequence.size() may return zero). If the list is not empty, the elements must describe valid struct members. (For example, the names must be unique within the type.) This argument may be null.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a struct.

TypeCode create_value_tc ( String  name,
short  type_modifier,
TypeCode  concrete_base,
ValueMember[]  members 
) throws BAD_PARAM

Constructs a TCKind.TK_VALUE TypeCode.

Parameters:
name <<in>> Name of the value type. Cannot be null.
type_modifier <<in>> One of the value type modifier constants: VM_NONE, VM_CUSTOM, VM_ABSTRACT or VM_TRUNCATABLE.
concrete_base <<in>> TypeCode object describing the concrete valuetype base. It may be null if the valuetype does not have a concrete base.
members <<in>> Initial members of the value type. This list may be empty. If the list is not empty, the elements must describe valid value type members. (For example, the names must be unique within the type.) This argument may be null.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a value.

TypeCode create_sparse_tc ( String  name,
short  type_modifier,
TypeCode  concrete_base 
) throws BAD_PARAM

Constructs a TCKind.TK_SPARSE TypeCode.

A sparse value type is similar to other value types but with one major difference: not all members need to be present in every sample.

It is not possible to generate code for sparse value types; they must be created at runtime using these APIs. You will interact with samples of sparse types using the Dynamic Data APIs.

Parameters:
name <<in>> Name of the value type. Cannot be null.
type_modifier <<in>> One of the value type modifier constants: VM_NONE, VM_CUSTOM, VM_ABSTRACT or VM_TRUNCATABLE.
concrete_base <<in>> TypeCode object describing the concrete valuetype base. It may be null if the valuetype does not have a concrete base.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a value.

TypeCode create_union_tc ( String  name,
TypeCode  discriminator_type,
int  default_index,
UnionMember[]  members 
) throws BAD_PARAM

Constructs a TCKind.TK_UNION TypeCode.

Parameters:
name <<in>> Name of the union type. Cannot be null.
discriminator_type <<in>> Discriminator Type Code. Cannot be null.
default_index <<in>> Index of the default member, or -1 if there is no default member.
members <<in>> Initial members of the union. This list may be empty. If the list is not empty, the elements must describe valid struct members. (For example, the names must be unique within the type.) This argument may be null.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a union.

TypeCode create_enum_tc ( String  name,
EnumMember[]  members 
) throws BAD_PARAM

Constructs a TCKind.TK_ENUM TypeCode.

Parameters:
name <<in>> Name of the enum type. Cannot be null.
members <<in>> Initial members of the enumeration. All members must have non-null names, and both names and ordinal values must be unique within the type. Note that it is also possible to add members later with TypeCode.add_member_to_enum. This argument may be null.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing an enumeration.

TypeCode create_alias_tc ( String  name,
TypeCode  original_type,
boolean  is_pointer 
) throws BAD_PARAM

Constructs a TCKind.TK_ALIAS (typedef) TypeCode.

Parameters:
name <<in>> Name of the alias. Cannot be null.
original_type <<in>> Aliased type code. Cannot be null.
is_pointer <<in>> Indicates if the alias is a pointer to the aliased type code.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing an alias.

TypeCode create_string_tc ( int  bound  )  throws BAD_PARAM

Constructs a TCKind.TK_STRING TypeCode.

Parameters:
bound <<in>> Maximum length of the string. It cannot be negative.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a string.

TypeCode create_wstring_tc ( int  bound  )  throws BAD_PARAM

Constructs a TCKind.TK_WSTRING TypeCode.

Parameters:
bound <<in>> Maximum length of the wide string. It cannot be negative.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a wide string.

TypeCode create_sequence_tc ( int  bound,
TypeCode  element_type 
) throws BAD_PARAM

Constructs a TCKind.TK_SEQUENCE TypeCode.

Parameters:
bound <<in>> The bound for the sequence (> 0).
element_type <<in>> TypeCode object describing the sequence elements.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a sequence.

TypeCode create_array_tc ( int[]  dimensions,
TypeCode  element_type 
) throws BAD_PARAM

Constructs a TCKind.TK_ARRAY TypeCode.

Parameters:
dimensions <<in>> Dimensions of the array. Each dimension has to be greater than 0.
element_type <<in>> TypeCode describing the array elements. Cannot be null.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a sequence.

TypeCode create_array_tc ( int  length,
TypeCode  element_type 
) throws BAD_PARAM

Constructs a TCKind.TK_ARRAY TypeCode for a single-dimensional array.

Parameters:
length <<in>> Length of the single-dimensional array.
element_type <<in>> TypeCode describing the array elements. Cannot be null.
Exceptions:
com.rti.dds.infrastructure.BAD_PARAM. Illegal parameter value.
Returns:
A newly-created TypeCode object describing a sequence.

TypeCode clone_tc ( TypeCode  tc  ) 

Creates and returns a copy of the input TypeCode.

Parameters:
tc <<in>> Type code that will be copied. Cannot be null.
Returns:
A clone of tc.

void delete_tc ( TypeCode  tc  ) 

Deletes the input TypeCode.

Calling this method is optional. If you do not call it, the garbage collector will perform the deletion when it is able.

Parameters:
tc <<inout>> Type code that will be deleted. Cannot be null.

TypeCode get_primitive_tc ( TCKind  kind  )  throws BAD_PARAM


RTI Connext Java API Version 4.5f Copyright © 17 Mar 2012 Real-Time Innovations, Inc