MAK RTIspy API Documentation for HLA 1.3
BasicDataElements.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: BasicDataElements.h
12 ***********************************************************************/
13 #ifndef RTI_BasicDataElements_h_
14 #define RTI_BasicDataElements_h_
15 
18 #include <RTI/SpecificConfig.h>
19 #include <string>
20 
21 // The following macro is used to define each of the encoding helper
22 // classes for basic C++ datatypes, e.g. HLAinteger16LE, HLAunicodeString,
23 // etc. Each kind of encoding helper contains the same set of operators
24 // and functions, but each is a separate class for type safety.
25 // Encoder uses either internal memory for value of native type or
26 // uses a supplied references to external memory of the native type.
27 // When used with a reference, the encoding and decoding is performed using
28 // the referenced instance of the native type.
29 #define DEFINE_ENCODING_HELPER_CLASS(EncodableDataType, SimpleDataType) \
30  \
31 /* Forward declaration for the RTI-internal class used to implement */ \
32 /* a specific kind of encoding helper */ \
33 class EncodableDataType##Implementation; \
34  \
35 class RTI_EXPORT EncodableDataType : public rti1516e::DataElement \
36 { \
37 public: \
38  \
39  /* Constructor: Default */ \
40  /* Uses internal memory. */ \
41  EncodableDataType(); \
42  \
43  /* Constructor: Initial Value */ \
44  /* Uses internal memory. */ \
45  explicit EncodableDataType ( \
46  SimpleDataType const & inData); \
47  \
48  /* Constructor: External memory */ \
49  /* This instance changes or is changed by contents of external memory. */ \
50  /* Caller is responsible for ensuring that the external memory is */ \
51  /* valid for the lifetime of this object or until this object acquires */ \
52  /* new memory through setDataPointer. */ \
53  /* A null value will construct instance to use internal memory. */ \
54  explicit EncodableDataType ( \
55  SimpleDataType* inData); \
56  \
57  /* Constructor: Copy */ \
58  /* Uses internal memory. */ \
59  EncodableDataType ( \
60  EncodableDataType const & rhs); \
61  \
62  /* Destructor */ \
63  virtual ~EncodableDataType (); \
64  \
65  /* Assignment Operator */ \
66  /* Uses existing memory of this instance. */ \
67  EncodableDataType& operator=( \
68  EncodableDataType const & rhs); \
69  \
70  /* Return a new copy of the DataElement */ \
71  /* Copy uses internal memory. */ \
72  virtual std::auto_ptr<DataElement> clone () const; \
73  \
74  /* Encode this element into a new VariableLengthData */ \
75  virtual VariableLengthData encode () const \
76  throw (EncoderException); \
77  \
78  /* Encode this element into an existing VariableLengthData */ \
79  virtual void encode ( \
80  VariableLengthData& inData) const \
81  throw (EncoderException); \
82  \
83  /* Encode this element and append it to a buffer */ \
84  virtual void encodeInto ( \
85  std::vector<Octet>& buffer) const \
86  throw (EncoderException); \
87  \
88  /* Decode this element from the RTI's VariableLengthData. */ \
89  virtual void decode ( \
90  VariableLengthData const & inData) \
91  throw (EncoderException); \
92  \
93  /* Decode this element starting at the index in the provided buffer */ \
94  /* Return the index immediately after the decoded data. */ \
95  virtual size_t decodeFrom ( \
96  std::vector<Octet> const & buffer, \
97  size_t index) \
98  throw (EncoderException); \
99  \
100  /* Return the size in bytes of this element's encoding. */ \
101  virtual size_t getEncodedLength () const \
102  throw (EncoderException); \
103  \
104  /* Return the octet boundary of this element. */ \
105  virtual unsigned int getOctetBoundary () const; \
106  \
107  /* Return a hash of the encoded data */ \
108  /* Provides mechanism to map DataElement discriminants to variants */ \
109  /* in VariantRecord. */ \
110  virtual Integer64 hash() const; \
111  \
112  /* Change this instance to use supplied external memory. */ \
113  /* Caller is responsible for ensuring that the external memory is */ \
114  /* valid for the lifetime of this object or until this object acquires */ \
115  /* new memory through this call. */ \
116  /* Null pointer results in an exception. */ \
117  virtual void setDataPointer ( \
118  SimpleDataType* inData) \
119  throw (EncoderException); \
120  \
121  /* Set the value to be encoded. */ \
122  /* If this element uses external memory, the memory will be modified. */ \
123  virtual void set ( \
124  SimpleDataType inData); \
125  \
126  /* Get the value from encoded data. */ \
127  virtual SimpleDataType get () const; \
128  \
129  /* Assignment of the value to be encoded data. */ \
130  /* If this element uses external memory, the memory will be modified. */ \
131  EncodableDataType & operator= ( \
132  SimpleDataType rhs); \
133  \
134  /* Conversion operator to SimpleDataType */ \
135  /* Return value from encoded data. */ \
136  operator SimpleDataType () const; \
137  \
138 protected: \
139  \
140  EncodableDataType##Implementation* _impl; \
141 };
142 
143 
144 namespace rti1516e
145 {
146  // Forward Declarations
147  class VariableLengthData;
148 
149  // All of the RTI API's Basic DataType Encoding Helper classes are
150  // defined by invoking the macro above.
151  DEFINE_ENCODING_HELPER_CLASS( HLAASCIIchar, char )
152  DEFINE_ENCODING_HELPER_CLASS( HLAASCIIstring, std::string )
153  DEFINE_ENCODING_HELPER_CLASS( HLAboolean, bool )
155  DEFINE_ENCODING_HELPER_CLASS( HLAfloat32BE, float )
156  DEFINE_ENCODING_HELPER_CLASS( HLAfloat32LE, float )
157  DEFINE_ENCODING_HELPER_CLASS( HLAfloat64BE, double )
158  DEFINE_ENCODING_HELPER_CLASS( HLAfloat64LE, double )
159  DEFINE_ENCODING_HELPER_CLASS( HLAinteger16LE, Integer16 )
160  DEFINE_ENCODING_HELPER_CLASS( HLAinteger16BE, Integer16 )
161  DEFINE_ENCODING_HELPER_CLASS( HLAinteger32BE, Integer32 )
162  DEFINE_ENCODING_HELPER_CLASS( HLAinteger32LE, Integer32 )
163  DEFINE_ENCODING_HELPER_CLASS( HLAinteger64BE, Integer64 )
164  DEFINE_ENCODING_HELPER_CLASS( HLAinteger64LE, Integer64 )
166  DEFINE_ENCODING_HELPER_CLASS( HLAoctetPairBE, OctetPair )
167  DEFINE_ENCODING_HELPER_CLASS( HLAoctetPairLE, OctetPair )
168  DEFINE_ENCODING_HELPER_CLASS( HLAunicodeChar, wchar_t )
169  DEFINE_ENCODING_HELPER_CLASS( HLAunicodeString, std::wstring )
170 
171 }
172 
173 #endif // RTI_BasicDataElements_h_
174 

Document ID: Generated on Tue May 7 16:26:47 EDT 2013 from SVN revision 126903
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)