![]() |
MAK RTIspy API Documentation for HLA 1.3
|
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: BasicDataElements.h 00012 ***********************************************************************/ 00013 #ifndef RTI_BasicDataElements_h_ 00014 #define RTI_BasicDataElements_h_ 00015 00016 #include <RTI/encoding/DataElement.h> 00017 #include <RTI/encoding/EncodingConfig.h> 00018 #include <RTI/SpecificConfig.h> 00019 #include <string> 00020 00021 // The following macro is used to define each of the encoding helper 00022 // classes for basic C++ datatypes, e.g. HLAinteger16LE, HLAunicodeString, 00023 // etc. Each kind of encoding helper contains the same set of operators 00024 // and functions, but each is a separate class for type safety. 00025 // Encoder uses either internal memory for value of native type or 00026 // uses a supplied references to external memory of the native type. 00027 // When used with a reference, the encoding and decoding is performed using 00028 // the referenced instance of the native type. 00029 #define DEFINE_ENCODING_HELPER_CLASS(EncodableDataType, SimpleDataType) \ 00030 \ 00031 /* Forward declaration for the RTI-internal class used to implement */ \ 00032 /* a specific kind of encoding helper */ \ 00033 class EncodableDataType##Implementation; \ 00034 \ 00035 class RTI_EXPORT EncodableDataType : public rti1516e::DataElement \ 00036 { \ 00037 public: \ 00038 \ 00039 /* Constructor: Default */ \ 00040 /* Uses internal memory. */ \ 00041 EncodableDataType(); \ 00042 \ 00043 /* Constructor: Initial Value */ \ 00044 /* Uses internal memory. */ \ 00045 explicit EncodableDataType ( \ 00046 SimpleDataType const & inData); \ 00047 \ 00048 /* Constructor: External memory */ \ 00049 /* This instance changes or is changed by contents of external memory. */ \ 00050 /* Caller is responsible for ensuring that the external memory is */ \ 00051 /* valid for the lifetime of this object or until this object acquires */ \ 00052 /* new memory through setDataPointer. */ \ 00053 /* A null value will construct instance to use internal memory. */ \ 00054 explicit EncodableDataType ( \ 00055 SimpleDataType* inData); \ 00056 \ 00057 /* Constructor: Copy */ \ 00058 /* Uses internal memory. */ \ 00059 EncodableDataType ( \ 00060 EncodableDataType const & rhs); \ 00061 \ 00062 /* Destructor */ \ 00063 virtual ~EncodableDataType (); \ 00064 \ 00065 /* Assignment Operator */ \ 00066 /* Uses existing memory of this instance. */ \ 00067 EncodableDataType& operator=( \ 00068 EncodableDataType const & rhs); \ 00069 \ 00070 /* Return a new copy of the DataElement */ \ 00071 /* Copy uses internal memory. */ \ 00072 virtual std::auto_ptr<DataElement> clone () const; \ 00073 \ 00074 /* Encode this element into a new VariableLengthData */ \ 00075 virtual VariableLengthData encode () const \ 00076 throw (EncoderException); \ 00077 \ 00078 /* Encode this element into an existing VariableLengthData */ \ 00079 virtual void encode ( \ 00080 VariableLengthData& inData) const \ 00081 throw (EncoderException); \ 00082 \ 00083 /* Encode this element and append it to a buffer */ \ 00084 virtual void encodeInto ( \ 00085 std::vector<Octet>& buffer) const \ 00086 throw (EncoderException); \ 00087 \ 00088 /* Decode this element from the RTI's VariableLengthData. */ \ 00089 virtual void decode ( \ 00090 VariableLengthData const & inData) \ 00091 throw (EncoderException); \ 00092 \ 00093 /* Decode this element starting at the index in the provided buffer */ \ 00094 /* Return the index immediately after the decoded data. */ \ 00095 virtual size_t decodeFrom ( \ 00096 std::vector<Octet> const & buffer, \ 00097 size_t index) \ 00098 throw (EncoderException); \ 00099 \ 00100 /* Return the size in bytes of this element's encoding. */ \ 00101 virtual size_t getEncodedLength () const \ 00102 throw (EncoderException); \ 00103 \ 00104 /* Return the octet boundary of this element. */ \ 00105 virtual unsigned int getOctetBoundary () const; \ 00106 \ 00107 /* Return a hash of the encoded data */ \ 00108 /* Provides mechanism to map DataElement discriminants to variants */ \ 00109 /* in VariantRecord. */ \ 00110 virtual Integer64 hash() const; \ 00111 \ 00112 /* Change this instance to use supplied external memory. */ \ 00113 /* Caller is responsible for ensuring that the external memory is */ \ 00114 /* valid for the lifetime of this object or until this object acquires */ \ 00115 /* new memory through this call. */ \ 00116 /* Null pointer results in an exception. */ \ 00117 virtual void setDataPointer ( \ 00118 SimpleDataType* inData) \ 00119 throw (EncoderException); \ 00120 \ 00121 /* Set the value to be encoded. */ \ 00122 /* If this element uses external memory, the memory will be modified. */ \ 00123 virtual void set ( \ 00124 SimpleDataType inData); \ 00125 \ 00126 /* Get the value from encoded data. */ \ 00127 virtual SimpleDataType get () const; \ 00128 \ 00129 /* Assignment of the value to be encoded data. */ \ 00130 /* If this element uses external memory, the memory will be modified. */ \ 00131 EncodableDataType & operator= ( \ 00132 SimpleDataType rhs); \ 00133 \ 00134 /* Conversion operator to SimpleDataType */ \ 00135 /* Return value from encoded data. */ \ 00136 operator SimpleDataType () const; \ 00137 \ 00138 protected: \ 00139 \ 00140 EncodableDataType##Implementation* _impl; \ 00141 }; 00142 00143 00144 namespace rti1516e 00145 { 00146 // Forward Declarations 00147 class VariableLengthData; 00148 00149 // All of the RTI API's Basic DataType Encoding Helper classes are 00150 // defined by invoking the macro above. 00151 DEFINE_ENCODING_HELPER_CLASS( HLAASCIIchar, char ) 00152 DEFINE_ENCODING_HELPER_CLASS( HLAASCIIstring, std::string ) 00153 DEFINE_ENCODING_HELPER_CLASS( HLAboolean, bool ) 00154 DEFINE_ENCODING_HELPER_CLASS( HLAbyte, Octet ) 00155 DEFINE_ENCODING_HELPER_CLASS( HLAfloat32BE, float ) 00156 DEFINE_ENCODING_HELPER_CLASS( HLAfloat32LE, float ) 00157 DEFINE_ENCODING_HELPER_CLASS( HLAfloat64BE, double ) 00158 DEFINE_ENCODING_HELPER_CLASS( HLAfloat64LE, double ) 00159 DEFINE_ENCODING_HELPER_CLASS( HLAinteger16LE, Integer16 ) 00160 DEFINE_ENCODING_HELPER_CLASS( HLAinteger16BE, Integer16 ) 00161 DEFINE_ENCODING_HELPER_CLASS( HLAinteger32BE, Integer32 ) 00162 DEFINE_ENCODING_HELPER_CLASS( HLAinteger32LE, Integer32 ) 00163 DEFINE_ENCODING_HELPER_CLASS( HLAinteger64BE, Integer64 ) 00164 DEFINE_ENCODING_HELPER_CLASS( HLAinteger64LE, Integer64 ) 00165 DEFINE_ENCODING_HELPER_CLASS( HLAoctet, Octet ) 00166 DEFINE_ENCODING_HELPER_CLASS( HLAoctetPairBE, OctetPair ) 00167 DEFINE_ENCODING_HELPER_CLASS( HLAoctetPairLE, OctetPair ) 00168 DEFINE_ENCODING_HELPER_CLASS( HLAunicodeChar, wchar_t ) 00169 DEFINE_ENCODING_HELPER_CLASS( HLAunicodeString, std::wstring ) 00170 00171 } 00172 00173 #endif // RTI_BasicDataElements_h_ 00174