![]() |
MAK RTIspy API Documentation for HLA 1516
|
00001 /*********************************************************************** 00002 The IEEE hereby grants a general, royalty-free license to copy, distribute, 00003 display and make derivative works from this material, for all purposes, 00004 provided that any use of the material contains the following 00005 attribution: "Reprinted with permission from IEEE 1516.1(TM)-2010". 00006 Should you require additional information, contact the Manager, Standards 00007 Intellectual Property, IEEE Standards Association (stds-ipr@ieee.org). 00008 ***********************************************************************/ 00009 /*********************************************************************** 00010 IEEE 1516.1 High Level Architecture Interface Specification C++ API 00011 File: HLAvariantRecord.h 00012 ***********************************************************************/ 00013 #ifndef RTI_HLAvariantRecord_h_ 00014 #define RTI_HLAvariantRecord_h_ 00015 00016 #include <RTI/encoding/DataElement.h> 00017 #include <RTI/encoding/EncodingConfig.h> 00018 #include <RTI/SpecificConfig.h> 00019 00020 namespace rti1516e 00021 { 00022 // Forward Declarations 00023 class VariableLengthData; 00024 class HLAvariantRecordImplementation; 00025 00026 // Interface for the HLAvariantRecord complex data element 00027 class RTI_EXPORT HLAvariantRecord : public rti1516e::DataElement 00028 { 00029 public: 00030 00031 // Constructor which accepts a prototype element for discriminants. 00032 // A clone of the given element acts to validate the discriminant type. 00033 explicit HLAvariantRecord ( 00034 DataElement const& discriminantPrototype); 00035 00036 // Copy Constructor 00037 HLAvariantRecord ( 00038 HLAvariantRecord const & rhs); 00039 00040 // Destructor 00041 virtual ~HLAvariantRecord (); 00042 00043 // Return a new copy of the DataElement 00044 virtual std::auto_ptr<DataElement> clone () const; 00045 00046 // Encode this element into a new VariableLengthData 00047 virtual VariableLengthData encode () const 00048 throw (EncoderException); 00049 00050 // Encode this element into an existing VariableLengthData 00051 virtual void encode ( 00052 VariableLengthData& inData) const 00053 throw (EncoderException); 00054 00055 // Encode this element and append it to a buffer 00056 virtual void encodeInto ( 00057 std::vector<Octet>& buffer) const 00058 throw (EncoderException); 00059 00060 // Decode this element from the RTI's VariableLengthData. 00061 virtual void decode ( 00062 VariableLengthData const & inData) 00063 throw (EncoderException); 00064 00065 // Decode this element starting at the index in the provided buffer 00066 virtual size_t decodeFrom ( 00067 std::vector<Octet> const & buffer, 00068 size_t index) 00069 throw (EncoderException); 00070 00071 // Return the size in bytes of this element's encoding. 00072 virtual size_t getEncodedLength () const 00073 throw (EncoderException); 00074 00075 // Return the octet boundary of this element. 00076 virtual unsigned int getOctetBoundary () const; 00077 00078 // Return true if given element is same type as this; otherwise, false. 00079 virtual bool isSameTypeAs( 00080 DataElement const& inData ) const; 00081 00082 // Return true if given element is same type as specified variant; otherwise, false. 00083 virtual bool isSameTypeAs(DataElement const& discriminant, 00084 DataElement const& inData ) const 00085 throw (EncoderException); 00086 00087 // Return true if given element matches prototype of this array. 00088 virtual bool hasMatchingDiscriminantTypeAs(DataElement const& dataElement ) const; 00089 00090 // Add a new discriminant/variant pair: adds a mapping between the given 00091 // unique discriminant and a copy of the value element. 00092 // When encoding, the last discriminant specified (either by adding or setDescriminant) 00093 // determines the value to be encoded. 00094 // When decoding, the encoded discriminant will determine which variant is 00095 // used. The getDescriminant call indicates the variant data element returned 00096 // by getValue. 00097 // Discriminants must match prototype 00098 virtual void addVariant ( 00099 const DataElement& discriminant, 00100 const DataElement& valuePrototype) 00101 throw (EncoderException); 00102 00103 // Add a new discriminant/variant pair: adds a mapping between the given 00104 // unique discriminant and the given value element. 00105 // When encoding, the last discriminant specified (either by adding or 00106 // setVariant, or setDescriminant) determines the value to be encoded. 00107 // When decoding, the encoded discriminant will determine which variant is 00108 // used. The getDescriminant call indicates the variant data element 00109 // returned by getValue. 00110 // Discriminants must match prototype 00111 // Caller is responsible for ensuring that the external memory is 00112 // valid for the lifetime of this object or until the variant for the 00113 // given discriminant acquires new memory through setVariantPointer. 00114 // Null pointer results in an exception. 00115 virtual void addVariantPointer ( 00116 const DataElement& discriminant, 00117 DataElement* valuePtr) 00118 throw (EncoderException); 00119 00120 // Set the current value of the discriminant (specifies the type of the value) 00121 // Discriminants must match prototype 00122 virtual void setDiscriminant ( 00123 const DataElement& discriminant) 00124 throw (EncoderException); 00125 00126 // Sets the variant with the given discriminant to a copy of the given value 00127 // Discriminant must match prototype and value must match its variant 00128 virtual void setVariant ( 00129 const DataElement& discriminant, 00130 DataElement const& value) 00131 throw (EncoderException); 00132 00133 // Sets the variant with the given discriminant to the given value 00134 // Discriminant must match prototype and value must match its variant 00135 // Caller is responsible for ensuring that the external memory is 00136 // valid for the lifetime of this object or until the variant for the 00137 // given discriminant acquires new memory through this call. 00138 // Null pointer results in an exception. 00139 virtual void setVariantPointer ( 00140 const DataElement& discriminant, 00141 DataElement* valuePtr) 00142 throw (EncoderException); 00143 00144 // Return a reference to the discriminant element 00145 virtual const DataElement& getDiscriminant () const; 00146 00147 // Return a reference to the variant element. 00148 // Exception thrown if encoded discriminant is not mapped to a value. 00149 virtual const DataElement& getVariant() const 00150 throw (EncoderException); 00151 00152 private: 00153 00154 // Default constructor not allowed 00155 HLAvariantRecord (); 00156 00157 // Assignment Operator not allowed 00158 HLAvariantRecord& operator=( 00159 HLAvariantRecord const & rhs); 00160 00161 protected: 00162 00163 HLAvariantRecordImplementation* _impl; 00164 }; 00165 } 00166 00167 #endif // RTI_HLAvariantRecord_h_ 00168