Back to CERTI User Documentation index
Variant Record

The template

 HLAvariantRecord<
   INDEX, DATATYPE,
   HLAvariantField<ENUMERATORS1, INDEX1, DATATYPE1,
   HLAvariantField<ENUMERATORS2, INDEX2, DATATYPE2,
   ...
   > ... > TYPENAME;

defines an ordered sequence of DATATYPE entries.

The data can be accessed using the field<INDEX>() function. The INDEX is a logical identifier only. The first field is a discriminant. It is followed by an alternative whose ENUMERATORS match the discriminant value.

For example:

 +-------------+-------------------------------+------------------------------------+------------------+-----------+
 |             | Discriminant                  | Alternative                        |                  |           |
 | Record name +------+-----------+------------+---------+--------------+-----------+ Encoding         | Semantics |
 |             | Name | Type      | Enumerator | Name    | Type         | Semantics |                  |           |
 +-------------+------+-----------+------------+---------+--------------+-----------+------------------+-----------+
 |             |      |           | AXIS_X     | FIELD_X | HLAfloat32LE |           |                  |           |
 | Coordinates | TYPE | TypesEnum +------------+---------+--------------+-----------+ HLAvariantRecord |           |
 |             |      |           | AXIS_Y     | FIELD_Y | HLAfloat32LE |           |                  |           |
 +-------------+------+-----------+------------+---------+--------------+-----------+------------------+-----------+
 
 namespace __Fields {
 enum __enum {
   TYPE = 0,
   FIELD_X = 101,
   FIELD_Y = 102
 };
 }
 typedef HLAenumeratedType<__Fields::__enum, HLAinteger32BE> Fields;
 typedef HLAvariantRecord<
   __Fields::TYPE, TypesEnum,
   HLAvariantField<HLAsetValue<AXIS_X>, __Fields::FIELD_X, HLAfloat32LE,
   HLAvariantField<HLAsetValue<AXIS_Y>, __Fields::FIELD_Y, HLAfloat32LE
   > > > Coordinates;
 HLAdata<Coordinates> value;

 value->set_discriminant(AXIS_X);
 value->field<__Fields::FIELD_X>() = 3.14;

Generated on Fri Feb 28 2014 16:33:59 for CERTIUserDocumentation by doxygen 1.8.6