MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HLAvariantRecord.h
Go to the documentation of this file.
1 /***********************************************************************
2  The IEEE hereby grants a general, royalty-free license to copy, distribute,
3  display and make derivative works from this material, for all purposes,
4  provided that any use of the material contains the following
5  attribution: "Reprinted with permission from IEEE 1516.1(TM)-2010".
6  Should you require additional information, contact the Manager, Standards
7  Intellectual Property, IEEE Standards Association (stds-ipr@ieee.org).
8 ***********************************************************************/
9 /***********************************************************************
10  IEEE 1516.1 High Level Architecture Interface Specification C++ API
11  File: HLAvariantRecord.h
12 ***********************************************************************/
13 #ifndef RTI_HLAvariantRecord_h_
14 #define RTI_HLAvariantRecord_h_
15 
18 #include <RTI/SpecificConfig.h>
19 
20 namespace rti1516e
21 {
22  // Forward Declarations
23  class VariableLengthData;
24  class HLAvariantRecordImplementation;
25 
26  // Interface for the HLAvariantRecord complex data element
28  {
29  public:
30 
31  // Constructor which accepts a prototype element for discriminants.
32  // A clone of the given element acts to validate the discriminant type.
33  explicit HLAvariantRecord (
34  DataElement const& discriminantPrototype);
35 
36  // Copy Constructor
38  HLAvariantRecord const & rhs);
39 
40  // Destructor
41  virtual ~HLAvariantRecord ();
42 
43  // Return a new copy of the DataElement
44  virtual std::auto_ptr<DataElement> clone () const;
45 
46  // Encode this element into a new VariableLengthData
47  virtual VariableLengthData encode () const
48  throw (EncoderException);
49 
50  // Encode this element into an existing VariableLengthData
51  virtual void encode (
52  VariableLengthData& inData) const
53  throw (EncoderException);
54 
55  // Encode this element and append it to a buffer
56  virtual void encodeInto (
57  std::vector<Octet>& buffer) const
58  throw (EncoderException);
59 
60  // Decode this element from the RTI's VariableLengthData.
61  virtual void decode (
62  VariableLengthData const & inData)
63  throw (EncoderException);
64 
65  // Decode this element starting at the index in the provided buffer
66  virtual size_t decodeFrom (
67  std::vector<Octet> const & buffer,
68  size_t index)
69  throw (EncoderException);
70 
71  // Return the size in bytes of this element's encoding.
72  virtual size_t getEncodedLength () const
73  throw (EncoderException);
74 
75  // Return the octet boundary of this element.
76  virtual unsigned int getOctetBoundary () const;
77 
78  // Return true if given element is same type as this; otherwise, false.
79  virtual bool isSameTypeAs(
80  DataElement const& inData ) const;
81 
82  // Return true if given element is same type as specified variant; otherwise, false.
83  virtual bool isSameTypeAs(DataElement const& discriminant,
84  DataElement const& inData ) const
85  throw (EncoderException);
86 
87  // Return true if given element matches prototype of this array.
88  virtual bool hasMatchingDiscriminantTypeAs(DataElement const& dataElement ) const;
89 
90  // Add a new discriminant/variant pair: adds a mapping between the given
91  // unique discriminant and a copy of the value element.
92  // When encoding, the last discriminant specified (either by adding or setDescriminant)
93  // determines the value to be encoded.
94  // When decoding, the encoded discriminant will determine which variant is
95  // used. The getDescriminant call indicates the variant data element returned
96  // by getValue.
97  // Discriminants must match prototype
98  virtual void addVariant (
99  const DataElement& discriminant,
100  const DataElement& valuePrototype)
101  throw (EncoderException);
102 
103  // Add a new discriminant/variant pair: adds a mapping between the given
104  // unique discriminant and the given value element.
105  // When encoding, the last discriminant specified (either by adding or
106  // setVariant, or setDescriminant) determines the value to be encoded.
107  // When decoding, the encoded discriminant will determine which variant is
108  // used. The getDescriminant call indicates the variant data element
109  // returned by getValue.
110  // Discriminants must match prototype
111  // Caller is responsible for ensuring that the external memory is
112  // valid for the lifetime of this object or until the variant for the
113  // given discriminant acquires new memory through setVariantPointer.
114  // Null pointer results in an exception.
115  virtual void addVariantPointer (
116  const DataElement& discriminant,
117  DataElement* valuePtr)
118  throw (EncoderException);
119 
120  // Set the current value of the discriminant (specifies the type of the value)
121  // Discriminants must match prototype
122  virtual void setDiscriminant (
123  const DataElement& discriminant)
124  throw (EncoderException);
125 
126  // Sets the variant with the given discriminant to a copy of the given value
127  // Discriminant must match prototype and value must match its variant
128  virtual void setVariant (
129  const DataElement& discriminant,
130  DataElement const& value)
131  throw (EncoderException);
132 
133  // Sets the variant with the given discriminant to the given value
134  // Discriminant must match prototype and value must match its variant
135  // Caller is responsible for ensuring that the external memory is
136  // valid for the lifetime of this object or until the variant for the
137  // given discriminant acquires new memory through this call.
138  // Null pointer results in an exception.
139  virtual void setVariantPointer (
140  const DataElement& discriminant,
141  DataElement* valuePtr)
142  throw (EncoderException);
143 
144  // Return a reference to the discriminant element
145  virtual const DataElement& getDiscriminant () const;
146 
147  // Return a reference to the variant element.
148  // Exception thrown if encoded discriminant is not mapped to a value.
149  virtual const DataElement& getVariant() const
150  throw (EncoderException);
151 
152  private:
153 
154  // Default constructor not allowed
155  HLAvariantRecord ();
156 
157  // Assignment Operator not allowed
158  HLAvariantRecord& operator=(
159  HLAvariantRecord const & rhs);
160 
161  protected:
162 
163  HLAvariantRecordImplementation* _impl;
164  };
165 }
166 
167 #endif // RTI_HLAvariantRecord_h_
168 
#define RTI_EXPORT
Definition: SpecificConfig.h:63
Definition: DataElement.h:28
Definition: EncodingExceptions.h:23
Definition: VariableLengthData.h:34
Definition: HLAvariantRecord.h:27
HLAvariantRecordImplementation * _impl
Definition: HLAvariantRecord.h:163
This file contains definitions that are used to isolate platform-specific elements of the API...

Document ID: Generated on Sun Jul 20 16:15:30 EDT 2025 from SVN revision 277985
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)