]> git.mxchange.org Git - simgear.git/blob - simgear/hla/HLAArrayDataType.hxx
Merge branch 'next' of git://gitorious.org/fg/simgear into next
[simgear.git] / simgear / hla / HLAArrayDataType.hxx
1 // Copyright (C) 2009 - 2011  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 bool decode(HLADecodeStream& stream, HLAAbstractArrayDataElement& value) const = 0;
39     virtual bool encode(HLAEncodeStream& stream, const HLAAbstractArrayDataElement& value) const = 0;
40
41     void setElementDataType(const HLADataType* elementDataType);
42     const HLADataType* getElementDataType() const
43     { return _elementDataType.get(); }
44
45     void setIsOpaque(bool isOpaque);
46     bool getIsOpaque() const
47     { return _isOpaque; }
48
49     void setIsString(bool isString);
50     bool getIsString() const
51     { return _isString; }
52
53 private:
54     SGSharedPtr<const HLADataType> _elementDataType;
55     bool _isOpaque;
56     bool _isString;
57 };
58
59 class HLAFixedArrayDataType : public HLAArrayDataType {
60 public:
61     HLAFixedArrayDataType(const std::string& name = "HLAFixedArrayDataType");
62     virtual ~HLAFixedArrayDataType();
63
64     virtual void accept(HLADataTypeVisitor& visitor) const;
65
66     virtual bool decode(HLADecodeStream& stream, HLAAbstractArrayDataElement& value) const;
67     virtual bool encode(HLAEncodeStream& stream, const HLAAbstractArrayDataElement& value) const;
68
69     void setNumElements(unsigned numElements)
70     { _numElements = numElements; }
71     unsigned getNumElements() const
72     { return _numElements; }
73
74 private:
75     unsigned _numElements;
76 };
77
78 class HLAVariableArrayDataType : public HLAArrayDataType {
79 public:
80     HLAVariableArrayDataType(const std::string& name = "HLAVariableArrayDataType");
81     virtual ~HLAVariableArrayDataType();
82
83     virtual void accept(HLADataTypeVisitor& visitor) const;
84
85     virtual bool decode(HLADecodeStream& stream, HLAAbstractArrayDataElement& value) const;
86     virtual bool encode(HLAEncodeStream& stream, const HLAAbstractArrayDataElement& value) const;
87
88     void setSizeDataType(const HLADataType* sizeDataType);
89     const HLADataType* getSizeDataType() const
90     { return _sizeDataType.get(); }
91
92 private:
93     SGSharedPtr<const HLADataType> _sizeDataType;
94 };
95
96 } // namespace simgear
97
98 #endif