]> git.mxchange.org Git - simgear.git/blob - simgear/hla/HLAArrayDataType.hxx
Merge branch 'timoore/optimizations' into next
[simgear.git] / simgear / hla / HLAArrayDataType.hxx
1 // Copyright (C) 2009 - 2012  Mathias Froehlich - Mathias.Froehlich@web.de
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Library General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16 //
17
18 #ifndef HLAArrayDataType_hxx
19 #define HLAArrayDataType_hxx
20
21 #include <string>
22 #include <simgear/structure/SGSharedPtr.hxx>
23 #include "HLADataType.hxx"
24
25 namespace simgear {
26
27 class HLAAbstractArrayDataElement;
28
29 class HLAArrayDataType : public HLADataType {
30 public:
31     HLAArrayDataType(const std::string& name = "HLAArrayDataType");
32     virtual ~HLAArrayDataType();
33
34     virtual void accept(HLADataTypeVisitor& visitor) const;
35
36     virtual const HLAArrayDataType* toArrayDataType() const;
37
38     virtual void releaseDataTypeReferences();
39
40     virtual bool decode(HLADecodeStream& stream, HLAAbstractArrayDataElement& value) const = 0;
41     virtual bool encode(HLAEncodeStream& stream, const HLAAbstractArrayDataElement& value) const = 0;
42
43     void setElementDataType(const HLADataType* elementDataType);
44     const HLADataType* getElementDataType() const
45     { return _elementDataType.get(); }
46
47     void setIsOpaque(bool isOpaque);
48     bool getIsOpaque() const
49     { return _isOpaque; }
50
51     void setIsString(bool isString);
52     bool getIsString() const
53     { return _isString; }
54
55 protected:
56     virtual void _recomputeAlignmentImplementation();
57
58 private:
59     SGSharedPtr<const HLADataType> _elementDataType;
60     bool _isOpaque;
61     bool _isString;
62 };
63
64 class HLAFixedArrayDataType : public HLAArrayDataType {
65 public:
66     HLAFixedArrayDataType(const std::string& name = "HLAFixedArrayDataType");
67     virtual ~HLAFixedArrayDataType();
68
69     virtual void accept(HLADataTypeVisitor& visitor) const;
70
71     virtual bool decode(HLADecodeStream& stream, HLAAbstractArrayDataElement& value) const;
72     virtual bool encode(HLAEncodeStream& stream, const HLAAbstractArrayDataElement& value) const;
73
74     void setNumElements(unsigned numElements)
75     { _numElements = numElements; }
76     unsigned getNumElements() const
77     { return _numElements; }
78
79 private:
80     unsigned _numElements;
81 };
82
83 class HLAVariableArrayDataType : public HLAArrayDataType {
84 public:
85     HLAVariableArrayDataType(const std::string& name = "HLAVariableArrayDataType");
86     virtual ~HLAVariableArrayDataType();
87
88     virtual void accept(HLADataTypeVisitor& visitor) const;
89
90     virtual bool decode(HLADecodeStream& stream, HLAAbstractArrayDataElement& value) const;
91     virtual bool encode(HLAEncodeStream& stream, const HLAAbstractArrayDataElement& value) const;
92
93     void setSizeDataType(const HLABasicDataType* sizeDataType);
94     const HLABasicDataType* getSizeDataType() const
95     { return _sizeDataType.get(); }
96
97 protected:
98     virtual void _recomputeAlignmentImplementation();
99
100 private:
101     SGSharedPtr<const HLABasicDataType> _sizeDataType;
102 };
103
104 } // namespace simgear
105
106 #endif