MAK RTIspy API Documentation for HLA Evolved
HLAfixedArrayImpl.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2010 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: HLAfixedArrayImpl.h,v $ $Revision: 1.0 $ $State: Exp $
00007 *********************************************************************/
00010 #ifndef HLAfixedArrayImpl_H_
00011 #define HLAfixedArrayImpl_H_
00012 
00013 #ifdef DtIFSPEC1516E
00014 
00015 #include <RTI/encoding/DataElement.h>
00016 #include "encodingImplHelpers.h"
00017 #include <memory>
00018 
00019 namespace rti1516e
00020 {
00021     class VariableLengthData;
00022 
00023     class HLAfixedArrayImplementation
00024     {
00025     public:
00026         // Constructor which initializes the array with copies of a prototype element
00027         HLAfixedArrayImplementation( const DataElement& proto, size_t length );
00028 
00029         // Copy Constructor: source must have same element type
00030         // Copied elements use internal memory
00031         HLAfixedArrayImplementation(HLAfixedArrayImplementation const & rhs)
00032             throw (EncoderException);
00033 
00034         // Destructor
00035         ~HLAfixedArrayImplementation();
00036 
00037         // Encode this element into a new rti1516e::VariableLengthData
00038         // @return a rti1516e::VariableLengthData containing an encoded element
00039         virtual rti1516e::VariableLengthData encode() const;
00040 
00041         // Encode this element into an existing rti1516e::VariableLengthData
00042         // @param data a rti1516e::VariableLengthData to which the element will be written
00043         virtual void encode(rti1516e::VariableLengthData& inData) const;
00044 
00045         // Encode this element and append it to a buffer
00046         // @param buffer a character buffer to which the encoding will be appended
00047         virtual void encodeInto( std::vector<Octet>& buffer ) const;
00048 
00049         // Decode this element from the RTI's VariableLengthData.
00050         // @param data a VariableLengthData containing an encoded element
00051         virtual void decode(rti1516e::VariableLengthData const & inData)
00052             throw (EncoderException);
00053 
00054         // Decode this element starting at the index in the provided buffer
00055         // @param buffer a character buffer from which the element will be decoded
00056         // @param index location of the encoded bytes in the buffer
00057         virtual size_t decodeFrom( std::vector<Octet> const & buffer, unsigned int index )
00058             throw (EncoderException);
00059 
00060         // Return the size in bytes of this element's encoding.
00061         // @return size
00062         virtual size_t getEncodedLength() const;
00063 
00064         // Return the octet boundary of this element.
00065         // @return the alignment of the element
00066         virtual unsigned int getOctetBoundary() const;
00067 
00068         // Return the number of elements in this fixed array.
00069         // @return
00070         virtual size_t size() const;
00071 
00072         // Return true if given element matches prototype of array.
00073         virtual bool hasPrototypeSameTypeAs(DataElement const& dataElement ) const;
00074 
00075         // Return true if the prototype of given array matches prototype of this array.
00076         virtual bool hasSamePrototypeTypeAs(HLAfixedArrayImplementation const& inData) const;
00077 
00078         // Sets the element at the given index to a copy of the given element instance
00079         // Element must match prototype.
00080         virtual void set(size_t index, const DataElement& dataElement)
00081             throw (EncoderException);
00082 
00083         // Sets the element at the given index to the given element instance
00084         // Element must match prototype.
00085         // Null pointer results in an exception.
00086         virtual void setElementPointer(size_t index, DataElement* dataElement,
00087             bool takeOwnership=false)
00088             throw (EncoderException);
00089 
00090         // Return the element at the specified index.
00091         // @param index
00092         // @return
00093         virtual const rti1516e::DataElement& get(
00094             size_t index) const
00095             throw (EncoderException);
00096 
00097     protected:
00098 
00099         // Reset the cached length if it has changed.
00100         // Return current encoded length
00101         virtual size_t resetEncodedLength( );
00102 
00103         // Empty and delete memory for existing elements.
00104         // Does not change array size
00105         virtual void clear( );
00106 
00107         // Remove const
00108         HLAfixedArrayImplementation* self() const;
00109 
00110     private:
00111 
00112         // Default Constructor not allowed
00113         HLAfixedArrayImplementation();
00114 
00115     private:
00116 
00117         std::auto_ptr<rti1516e::DataElement> myPrototypeElement;
00118         mutable std::vector<rti1516e::DataElement*> myData;
00119         mutable std::vector<bool> myDataOwnership;
00120         bool myDirtyState;
00121         unsigned int myOctetBoundary;
00122         unsigned int myEncodedLength;
00123     };
00124 }
00125 
00126 #endif
00127 #endif  // DtIFSPEC1516E
00128 
00129 

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)