MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HLAfixedArrayImpl.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2010 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: HLAfixedArrayImpl.h,v $ $Revision: 1.0 $ $State: Exp $
7 *********************************************************************/
10 #ifndef HLAfixedArrayImpl_H_
11 #define HLAfixedArrayImpl_H_
12 
13 #if !defined(DtIFSPEC13) && !defined(DtIFSPEC1516)
14 
16 #include <encodingImplHelpers.h>
17 #include <rtiApiTypes.h>
18 
19 #include <memory>
20 
21 namespace RTI_API
22 {
23  class VariableLengthData;
24 
26  {
27  public:
28  // Constructor which initializes the array with copies of a prototype element
29  HLAfixedArrayImplementation( const DataElement& proto, size_t length );
30 
31  // Copy Constructor: source must have same element type
32  // Copied elements use internal memory
34  throw (EncoderException);
35 
36  // Destructor
38 
39  // Encode this element into a new VariableLengthData
40  // @return a VariableLengthData containing an encoded element
41  virtual VariableLengthData encode() const;
42 
43  // Encode this element into an existing VariableLengthData
44  // @param data a VariableLengthData to which the element will be written
45  virtual void encode(VariableLengthData& inData) const;
46 
47  // Encode this element and append it to a buffer
48  // @param buffer a character buffer to which the encoding will be appended
49  virtual void encodeInto( std::vector<Octet>& buffer ) const;
50 
51  // Decode this element from the RTI's VariableLengthData.
52  // @param data a VariableLengthData containing an encoded element
53  virtual void decode(VariableLengthData const & inData)
54  throw (EncoderException);
55 
56  // Decode this element starting at the index in the provided buffer
57  // @param buffer a character buffer from which the element will be decoded
58  // @param index location of the encoded bytes in the buffer
59  virtual size_t decodeFrom( std::vector<Octet> const & buffer, unsigned int index )
60  throw (EncoderException);
61 
62  // Return the size in bytes of this element's encoding.
63  // @return size
64  virtual size_t getEncodedLength() const;
65 
66  // Return the octet boundary of this element.
67  // @return the alignment of the element
68  virtual unsigned int getOctetBoundary() const;
69 
70  // Return the number of elements in this fixed array.
71  // @return
72  virtual size_t size() const;
73 
74  // Return true if given element matches prototype of array.
75  virtual bool hasPrototypeSameTypeAs(DataElement const& dataElement ) const;
76 
77  // Return true if the prototype of given array matches prototype of this array.
78  virtual bool hasSamePrototypeTypeAs(HLAfixedArrayImplementation const& inData) const;
79 
80  // Sets the element at the given index to a copy of the given element instance
81  // Element must match prototype.
82  virtual void set(size_t index, const DataElement& dataElement)
83  throw (EncoderException);
84 
85  // Sets the element at the given index to the given element instance
86  // Element must match prototype.
87  // Null pointer results in an exception.
88  virtual void setElementPointer(size_t index, DataElement* dataElement,
89  bool takeOwnership=false)
90  throw (EncoderException);
91 
92  // Return the element at the specified index.
93  // @param index
94  // @return
95  virtual const DataElement& get(
96  size_t index) const
97  throw (EncoderException);
98 
99  protected:
100 
101  // Reset the cached length if it has changed.
102  // Return current encoded length
103  virtual size_t resetEncodedLength( );
104 
105  // Empty and delete memory for existing elements.
106  // Does not change array size
107  virtual void clear( );
108 
109  // Remove const
110  HLAfixedArrayImplementation* self() const;
111 
112  private:
113 
114  // Default Constructor not allowed
116 
117  private:
118 
119  DtRtiApiUniquePtr<DataElement> myPrototypeElement;
120  mutable std::vector<DataElement*> myData;
121  mutable std::vector<bool> myDataOwnership;
123  unsigned int myOctetBoundary;
124  unsigned int myEncodedLength;
125  };
126 }
127 
128 #endif
129 #endif
virtual bool hasPrototypeSameTypeAs(DataElement const &dataElement) const
virtual void encodeInto(std::vector< Octet > &buffer) const
bool myDirtyState
Definition: HLAfixedArrayImpl.h:122
virtual void set(size_t index, const DataElement &dataElement)
virtual void decode(VariableLengthData const &inData)
virtual unsigned int getOctetBoundary() const
DtRtiApiUniquePtr< DataElement > myPrototypeElement
Definition: HLAfixedArrayImpl.h:119
virtual void setElementPointer(size_t index, DataElement *dataElement, bool takeOwnership=false)
virtual VariableLengthData encode() const
virtual bool hasSamePrototypeTypeAs(HLAfixedArrayImplementation const &inData) const
virtual size_t decodeFrom(std::vector< Octet > const &buffer, unsigned int index)
Definition: HLAfixedArrayImpl.h:25
virtual size_t size() const
virtual size_t getEncodedLength() const
unsigned int myEncodedLength
Definition: HLAfixedArrayImpl.h:124
std::vector< DataElement * > myData
Definition: HLAfixedArrayImpl.h:120
unsigned int myOctetBoundary
Definition: HLAfixedArrayImpl.h:123
std::vector< bool > myDataOwnership
Definition: HLAfixedArrayImpl.h:121

Document ID: Generated on Wed Jul 8 16:20:32 EDT 2026 from SVN revision 291616
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)