CoreDX DDS
C++ Reference Manual

DDS::UnionDynamicType Class Reference
[CoreDX DDS DynamicTypes]

Represents a union. More...

Inheritance diagram for DDS::UnionDynamicType:
DDS::DynamicType

List of all members.

Public Member Functions

uint32_t get_num_fields ()
 Provides access to the number of fields held by a STRUCT or UNION DynamicType object.
DynamicTypeget_field (uint32_t n)
 Provides access to a field held by a STRUCT or UNION DynamicType object.
const char * get_field_name (uint32_t n)
 Provides access to the name of a field held by a STRUCT or UNION DynamicType object.
DynamicTypeget_discriminator ()
 Provides access to the 'discriminator' type of a UNION DynamicType object.
int32_t get_default_field ()
 Provides access to the 'default' field of a UNION DynamicType object.
uint32_t get_field_num_labels (uint32_t field)
 Provides access to the number of labels assigned to a field in the UNION DynamicType object.
int32_t get_field_label (uint32_t field, uint32_t label)
 Provides access to the number of labels assigned to a field in the UNION DynamicType object.
DynamicTypeget_selected_field (void)
 Provides access to the field selected by the discriminator (or the default).
ReturnCode_t set_num_fields (uint32_t n)
 Defines the number of fields held by a STRUCT or UNION DynamicType object.
ReturnCode_t set_field (uint32_t n, const char *field_name, DynamicType *e)
 Assigns a value to a field of a STRUCT or UNION DynamicType object.
ReturnCode_t set_discriminator (DynamicType *d)
 Defines the type and value of the UNION discriminator.
ReturnCode_t set_default_field (int32_t field)
 Defines the index of the default field within the UNION.
ReturnCode_t set_field_num_labels (uint32_t field, uint32_t n)
 Defines the number of labels associated with a field within the UNION.
ReturnCode_t set_field_label (uint32_t field, uint32_t label, int32_t val)
 Assigns a label to the specified field within the UNION.

Detailed Description

Represents a union.


Member Function Documentation

int32_t DDS::UnionDynamicType::get_default_field (  ) 

Provides access to the 'default' field of a UNION DynamicType object.

This is applicable only for a UNION DynamicType object. This returns the index of the 'default' field in the UNION, if there is no field marked with a 'default:' case label.

Return values:
int32_t the index of the 'default' field. -1 if there is no defined 'default' case.
DynamicType* DDS::UnionDynamicType::get_discriminator (  ) 

Provides access to the 'discriminator' type of a UNION DynamicType object.

This is applicable only for a UNION DynamicType object. This returns the DynamicType that serves as a discriminator for the UNION data structure.

Return values:
DynamicType the discriminator data.
DynamicType* DDS::UnionDynamicType::get_field ( uint32_t  n  ) 

Provides access to a field held by a STRUCT or UNION DynamicType object.

This is applicable for a STRUCT or UNION DynamicType object. For a STRUCT or UNION, this returns a field held in the data structure.

Return values:
DynamicType the number of data fields in the STRUCT or UNION 't'.
int32_t DDS::UnionDynamicType::get_field_label ( uint32_t  field,
uint32_t  label 
)

Provides access to the number of labels assigned to a field in the UNION DynamicType object.

This is applicable only for a UNION DynamicType object. This returns the count of the number of labels used to select a particular field in the UNION. The 'default:' label is not included in this count - as a result, it is possible for one field to have 'zero' labels.

Return values:
int32_t the number of labels assigned to field identified by index 'field'.
const char* DDS::UnionDynamicType::get_field_name ( uint32_t  n  ) 

Provides access to the name of a field held by a STRUCT or UNION DynamicType object.

This is applicable for a STRUCT or UNION DynamicType object. For a STRUCT or UNION, this returns the name of a field held in the data structure.

Return values:
const_char_* field name of field 'n' in STRUCT or UNION 't'.
uint32_t DDS::UnionDynamicType::get_field_num_labels ( uint32_t  field  ) 

Provides access to the number of labels assigned to a field in the UNION DynamicType object.

This is applicable only for a UNION DynamicType object. This returns the count of the number of labels used to select a particular field in the UNION. The 'default:' label is not included in this count.

Return values:
int32_t the number of labels assigned to field identified by index 'field'.
uint32_t DDS::UnionDynamicType::get_num_fields (  ) 

Provides access to the number of fields held by a STRUCT or UNION DynamicType object.

This is applicable for a STRUCT or UNION DynamicType object. For a STRUCT, this returns the number of fields held in the structure. For a UNION, this returns the number of fields contained by the UNION where a field is selectable by one or more case labels.

Return values:
uint32_t the number of data fields in the STRUCT or UNION 't'.
DynamicType* DDS::UnionDynamicType::get_selected_field ( void   ) 

Provides access to the field selected by the discriminator (or the default).

This is applicable only for union instances that have an initialized 'discriminator' value. This returns the field selected by the discriminator value (or by the 'default' value if the discriminator does not identify a field).

Return values:
DynamicType *, or NULL if the discriminator is not associated with a field and there is no default.
ReturnCode_t DDS::UnionDynamicType::set_default_field ( int32_t  field  ) 

Defines the index of the default field within the UNION.

The active field in the UNION is selected by considering the value of the discriminator and the values of the field labels. Any value of the discriminator not explicitly listed in the labels will select the default field. The default field may have other labels assigned to it, or it may have zero labels.

Note:
An index value of -1 indicates that the UNION has no default field.
Return values:
BAD_PARAMETER if 't' is not of type UNION.
OK upon success.
ReturnCode_t DDS::UnionDynamicType::set_discriminator ( DynamicType d  ) 

Defines the type and value of the UNION discriminator.

The discriminator is used to identify which one of the UNION fields is active. Only one field within the UNION is active at a given time. The active field is selected by considering the value of the discriminator and the values of the field labels. Each field can have a set of labels containing zero or more unique discriminator values. Field labels are defined with the set_field_num_labels() and set_field_label() functions.

Note:
The UNION takes ownership of the provided discriminator.
One field in the union can be designated as the 'default' field. Any value of the discriminator not explicitly listed in the labels will select the default field. The default field may have other labels assigned to it, or it may have zero labels.
Return values:
BAD_PARAMETER if 't' is not of type UNION.
OK upon success.
ReturnCode_t DDS::UnionDynamicType::set_field ( uint32_t  n,
const char *  field_name,
DynamicType e 
)

Assigns a value to a field of a STRUCT or UNION DynamicType object.

The 'nth' field of the struct or union is assigned the provided field_name, type e. This routine makes a copy of the 'field_name' argument.

Note:
The STRUCT or UNION takes ownership of the provided field.
Fields of a UNION data type can not be part of a 'key set', as the field may not exist in a particular instantiation of the union data type.
Return values:
BAD_PARAMETER if 't' is not of type STRUCT or UNION.
OUT_OF_MEMORY if memory allocation (to hold a copy of field_name) fails.
OK upon success.
ReturnCode_t DDS::UnionDynamicType::set_field_label ( uint32_t  field,
uint32_t  label,
int32_t  val 
)

Assigns a label to the specified field within the UNION.

Return values:
BAD_PARAMETER if 't' is not of type UNION or if field does not specify a valid field index, or if label does not specify a valid label index for the field.
OUT_OF_RESOURCES if memory allocation fails.
OK upon success.
ReturnCode_t DDS::UnionDynamicType::set_field_num_labels ( uint32_t  field,
uint32_t  n 
)

Defines the number of labels associated with a field within the UNION.

Each field in a UNION has zero or more labels associated. The active field in the UNION is selected by considering the value of the discriminator and the values of the field labels. A field is selected when the value of the discriminator matches the value of one of its labels. Any value of the discriminator not explicitly listed in the all of the labels will select the default field. [The default field may have other labels assigned to it, or it may have zero labels.]

Note:
Subsequent calls to this routine for the same field will clear any previously assigned labels. [The default field may have other labels assigned to it, or it may have zero labels.]
Return values:
BAD_PARAMETER if 't' is not of type UNION.
OUT_OF_RESOURCES if memory allocation fails.
OK upon success.
ReturnCode_t DDS::UnionDynamicType::set_num_fields ( uint32_t  n  ) 

Defines the number of fields held by a STRUCT or UNION DynamicType object.

Return values:
BAD_PARAMETER if 't' is not of type STRUCT or UNION.
OK upon success.
 All Classes Files Functions Variables

© 2009-2013 Twin Oaks Computing, Inc
Castle Rock, CO 80108
All rights reserved.