MAK RTIspy API Documentation for HLA 4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BasicDataElements.h
Go to the documentation of this file.
1 #pragma once
2 /***********************************************************************
3  The IEEE hereby grants a general, royalty-free license to copy, distribute,
4  display and make derivative works from this material, for all purposes,
5  provided that any use of the material contains the following
6  attribution: "Reprinted with permission from IEEE 1516.1(TM)-2025".
7  Should you require additional information, contact the Manager, Standards
8  Intellectual Property, IEEE Standards Association (stds-ipr@ieee.org).
9 ***********************************************************************/
10 
13 #include <RTI/SpecificConfig.h>
14 #include <string>
15 
16 // The following macro is used to define each of the encoding helper
17 // classes for basic C++ datatypes, e.g. HLAinteger16LE, HLAunicodeString,
18 // etc. Each kind of encoding helper contains the same set of operators
19 // and functions, but each is a separate class for type safety.
20 // Encoder uses either internal memory for value of native type or
21 // uses a supplied references to external memory of the native type.
22 // When used with a reference, the encoding and decoding is performed using
23 // the referenced instance of the native type.
24 #define DEFINE_ENCODING_HELPER_CLASS(EncodableDataType, SimpleDataType) \
25  \
26 /* Forward declaration for the RTI-internal class used to implement */ \
27 /* a specific kind of encoding helper */ \
28 class EncodableDataType##Implementation; \
29  \
30 class RTI_EXPORT EncodableDataType : public rti1516_2025::DataElement \
31 { \
32 public: \
33  \
34  /* Constructor: Default */ \
35  /* Uses internal memory. */ \
36  EncodableDataType(); \
37  \
38  /* Constructor: Initial Value */ \
39  /* Uses internal memory. */ \
40  explicit EncodableDataType ( \
41  SimpleDataType const & inData); \
42  \
43  /* Constructor: External memory */ \
44  /* This instance changes or is changed by contents of external memory. */ \
45  /* Caller is responsible for ensuring that the external memory is */ \
46  /* valid for the lifetime of this object or until this object acquires */ \
47  /* new memory through setDataPointer. */ \
48  /* A null value will construct instance to use internal memory. */ \
49  explicit EncodableDataType ( \
50  SimpleDataType* inData); \
51  \
52  /* Constructor: Copy */ \
53  /* Uses internal memory. */ \
54  EncodableDataType ( \
55  EncodableDataType const & rhs); \
56  \
57  /* Destructor */ \
58  virtual ~EncodableDataType (); \
59  \
60  /* Assignment Operator */ \
61  /* Uses existing memory of this instance. */ \
62  EncodableDataType& operator=( \
63  EncodableDataType const & rhs); \
64  \
65  /* Return a new copy of the DataElement */ \
66  /* Copy uses internal memory. */ \
67  virtual std::unique_ptr<DataElement> clone () const; \
68  \
69  /* Encode this element into a new VariableLengthData */ \
70  \
71  virtual VariableLengthData encode () const; \
72  \
73  /* Encode this element into an existing VariableLengthData */ \
74  \
75  virtual void encode ( \
76  VariableLengthData& inData) const; \
77  \
78  /* Encode this element and append it to a buffer */ \
79  \
80  virtual void encodeInto ( \
81  std::vector<Octet>& buffer) const; \
82  \
83  /* Decode this element from the RTI's VariableLengthData. */ \
84  \
85  virtual EncodableDataType& decode ( \
86  VariableLengthData const & inData); \
87  \
88  /* Decode this element starting at the index in the provided buffer */ \
89  /* Return the index immediately after the decoded data. */ \
90  \
91  virtual size_t decodeFrom ( \
92  std::vector<Octet> const & buffer, \
93  size_t index); \
94  \
95  /* Return the size in bytes of this element's encoding. */ \
96  \
97  virtual size_t getEncodedLength () const; \
98  \
99  /* Return the octet boundary of this element. */ \
100  virtual unsigned int getOctetBoundary () const; \
101  \
102  /* Return a hash of the encoded data */ \
103  /* Provides mechanism to map DataElement discriminants to variants */ \
104  /* in VariantRecord. */ \
105  virtual Integer64 hash() const; \
106  \
107  /* Change this instance to use supplied external memory. */ \
108  /* Caller is responsible for ensuring that the external memory is */ \
109  /* valid for the lifetime of this object or until this object acquires */ \
110  /* new memory through this call. */ \
111  /* Null pointer results in an exception. */ \
112  \
113  virtual void setDataPointer ( \
114  SimpleDataType* inData); \
115  \
116  /* Set the value to be encoded. */ \
117  /* If this element uses external memory, the memory will be modified. */ \
118  virtual EncodableDataType & set ( \
119  SimpleDataType inData); \
120  \
121  /* Get the value from encoded data. */ \
122  virtual SimpleDataType get () const; \
123  \
124  /* Assignment of the value to be encoded data. */ \
125  /* If this element uses external memory, the memory will be modified. */ \
126  EncodableDataType & operator= ( \
127  SimpleDataType rhs); \
128  \
129  /* Conversion operator to SimpleDataType */ \
130  /* Return value from encoded data. */ \
131  operator SimpleDataType () const; \
132  \
133 protected: \
134  \
135  EncodableDataType##Implementation* _impl; \
136 };
137 
138 
139 namespace rti1516_2025
140 {
141  // Forward Declarations
142  class VariableLengthData;
143 
144  // All of the RTI API's Basic DataType Encoding Helper classes are
145  // defined by invoking the macro above.
146  DEFINE_ENCODING_HELPER_CLASS( HLAASCIIchar, char )
147  DEFINE_ENCODING_HELPER_CLASS( HLAASCIIstring, std::string )
148  DEFINE_ENCODING_HELPER_CLASS( HLAboolean, bool )
150  DEFINE_ENCODING_HELPER_CLASS( HLAfloat32BE, float )
151  DEFINE_ENCODING_HELPER_CLASS( HLAfloat32LE, float )
152  DEFINE_ENCODING_HELPER_CLASS( HLAfloat64BE, double )
153  DEFINE_ENCODING_HELPER_CLASS( HLAfloat64LE, double )
154  DEFINE_ENCODING_HELPER_CLASS( HLAinteger16LE, Integer16 )
155  DEFINE_ENCODING_HELPER_CLASS( HLAinteger16BE, Integer16 )
156  DEFINE_ENCODING_HELPER_CLASS( HLAinteger32BE, Integer32 )
157  DEFINE_ENCODING_HELPER_CLASS( HLAinteger32LE, Integer32 )
158  DEFINE_ENCODING_HELPER_CLASS( HLAinteger64BE, Integer64 )
159  DEFINE_ENCODING_HELPER_CLASS( HLAinteger64LE, Integer64 )
160  DEFINE_ENCODING_HELPER_CLASS( HLAunsignedInteger16LE, UnsignedInteger16 )
161  DEFINE_ENCODING_HELPER_CLASS( HLAunsignedInteger16BE, UnsignedInteger16 )
162  DEFINE_ENCODING_HELPER_CLASS( HLAunsignedInteger32BE, UnsignedInteger32 )
163  DEFINE_ENCODING_HELPER_CLASS( HLAunsignedInteger32LE, UnsignedInteger32 )
164  DEFINE_ENCODING_HELPER_CLASS( HLAunsignedInteger64BE, UnsignedInteger64 )
165  DEFINE_ENCODING_HELPER_CLASS( HLAunsignedInteger64LE, UnsignedInteger64 )
167  DEFINE_ENCODING_HELPER_CLASS( HLAoctetPairBE, OctetPair )
168  DEFINE_ENCODING_HELPER_CLASS( HLAoctetPairLE, OctetPair )
169  DEFINE_ENCODING_HELPER_CLASS( HLAunicodeChar, wchar_t )
170  DEFINE_ENCODING_HELPER_CLASS( HLAunicodeString, std::wstring )
171 
172 }
173 
174 
175 
unsigned long long UnsignedInteger64
Definition: EncodingConfig.h:45
unsigned short UnsignedInteger16
Definition: EncodingConfig.h:43
short Integer16
Definition: EncodingConfig.h:39
#define DEFINE_ENCODING_HELPER_CLASS(EncodableDataType, SimpleDataType)
Definition: BasicDataElements.h:24
Integer8 Octet
Definition: EncodingConfig.h:49
long long Integer64
Definition: EncodingConfig.h:41
std::pair< Octet, Octet > OctetPair
Definition: EncodingConfig.h:50
This file contains definitions that are used to isolate platform-specific elements of the API...
unsigned int UnsignedInteger32
Definition: EncodingConfig.h:44
int Integer32
Definition: EncodingConfig.h:40

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)