MAK RTIspy API Documentation for HLA 1516
 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 #ifdef DtIFSPEC1516E
14 
16 #include "encodingImplHelpers.h"
17 #include <memory>
18 
19 namespace rti1516e
20 {
21  class VariableLengthData;
22 
23  class HLAfixedArrayImplementation
24  {
25  public:
26  // Constructor which initializes the array with copies of a prototype element
27  HLAfixedArrayImplementation( const DataElement& proto, size_t length );
28 
29  // Copy Constructor: source must have same element type
30  // Copied elements use internal memory
31  HLAfixedArrayImplementation(HLAfixedArrayImplementation const & rhs)
32  throw (EncoderException);
33 
34  // Destructor
35  ~HLAfixedArrayImplementation();
36 
37  // Encode this element into a new rti1516e::VariableLengthData
38  // @return a rti1516e::VariableLengthData containing an encoded element
39  virtual rti1516e::VariableLengthData encode() const;
40 
41  // Encode this element into an existing rti1516e::VariableLengthData
42  // @param data a rti1516e::VariableLengthData to which the element will be written
43  virtual void encode(rti1516e::VariableLengthData& inData) const;
44 
45  // Encode this element and append it to a buffer
46  // @param buffer a character buffer to which the encoding will be appended
47  virtual void encodeInto( std::vector<Octet>& buffer ) const;
48 
49  // Decode this element from the RTI's VariableLengthData.
50  // @param data a VariableLengthData containing an encoded element
51  virtual void decode(rti1516e::VariableLengthData const & inData)
52  throw (EncoderException);
53 
54  // Decode this element starting at the index in the provided buffer
55  // @param buffer a character buffer from which the element will be decoded
56  // @param index location of the encoded bytes in the buffer
57  virtual size_t decodeFrom( std::vector<Octet> const & buffer, unsigned int index )
58  throw (EncoderException);
59 
60  // Return the size in bytes of this element's encoding.
61  // @return size
62  virtual size_t getEncodedLength() const;
63 
64  // Return the octet boundary of this element.
65  // @return the alignment of the element
66  virtual unsigned int getOctetBoundary() const;
67 
68  // Return the number of elements in this fixed array.
69  // @return
70  virtual size_t size() const;
71 
72  // Return true if given element matches prototype of array.
73  virtual bool hasPrototypeSameTypeAs(DataElement const& dataElement ) const;
74 
75  // Return true if the prototype of given array matches prototype of this array.
76  virtual bool hasSamePrototypeTypeAs(HLAfixedArrayImplementation const& inData) const;
77 
78  // Sets the element at the given index to a copy of the given element instance
79  // Element must match prototype.
80  virtual void set(size_t index, const DataElement& dataElement)
81  throw (EncoderException);
82 
83  // Sets the element at the given index to the given element instance
84  // Element must match prototype.
85  // Null pointer results in an exception.
86  virtual void setElementPointer(size_t index, DataElement* dataElement,
87  bool takeOwnership=false)
88  throw (EncoderException);
89 
90  // Return the element at the specified index.
91  // @param index
92  // @return
93  virtual const rti1516e::DataElement& get(
94  size_t index) const
95  throw (EncoderException);
96 
97  protected:
98 
99  // Reset the cached length if it has changed.
100  // Return current encoded length
101  virtual size_t resetEncodedLength( );
102 
103  // Empty and delete memory for existing elements.
104  // Does not change array size
105  virtual void clear( );
106 
107  // Remove const
108  HLAfixedArrayImplementation* self() const;
109 
110  private:
111 
112  // Default Constructor not allowed
113  HLAfixedArrayImplementation();
114 
115  private:
116 
117  std::auto_ptr<rti1516e::DataElement> myPrototypeElement;
118  mutable std::vector<rti1516e::DataElement*> myData;
119  mutable std::vector<bool> myDataOwnership;
120  bool myDirtyState;
121  unsigned int myOctetBoundary;
122  unsigned int myEncodedLength;
123  };
124 }
125 
126 #endif
127 #endif // DtIFSPEC1516E
128 
129 

Document ID: Generated on Wed Mar 11 20:26:49 EDT 2015 from SVN revision 150939
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)