]> git.mxchange.org Git - simgear.git/blob - simgear/hla/HLADataType.hxx
hla: Add new header containing some enums.
[simgear.git] / simgear / hla / HLADataType.hxx
1 // Copyright (C) 2009 - 2010  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 HLADataType_hxx
19 #define HLADataType_hxx
20
21 #include <string>
22 #include <simgear/structure/SGWeakPtr.hxx>
23 #include <simgear/structure/SGWeakReferenced.hxx>
24 #include "RTIData.hxx"
25
26 namespace simgear {
27
28 class HLADataTypeVisitor;
29
30 class HLADataTypeReference;
31 class HLABasicDataType;
32 class HLAArrayDataType;
33 class HLAEnumeratedDataType;
34 class HLAFixedRecordDataType;
35 class HLAVariantRecordDataType;
36
37 class HLADataType : public SGWeakReferenced {
38 public:
39     virtual ~HLADataType();
40
41     const std::string& getName() const
42     { return _name; }
43
44     const std::string& getSemantics() const
45     { return _semantics; }
46     void setSemantics(const std::string& semantics)
47     { _semantics = semantics; }
48
49     unsigned getAlignment() const
50     { return _alignment; }
51
52     virtual void accept(HLADataTypeVisitor& visitor) const;
53
54     virtual const HLADataTypeReference* toDataTypeReference() const;
55     virtual const HLABasicDataType* toBasicDataType() const;
56     virtual const HLAArrayDataType* toArrayDataType() const;
57     virtual const HLAEnumeratedDataType* toEnumeratedDataType() const;
58     virtual const HLAFixedRecordDataType* toFixedRecordDataType() const;
59     /// deprecated
60     const HLAVariantRecordDataType* toVariantDataType() const { return toVariantRecordDataType(); }
61     virtual const HLAVariantRecordDataType* toVariantRecordDataType() const;
62
63 protected:
64     HLADataType(const std::string& name, unsigned alignment = 1);
65     void setAlignment(unsigned alignment);
66
67 private:
68     std::string _name;
69     std::string _semantics;
70     unsigned _alignment;
71 };
72
73 // Weak reference to a data type. Used to implement self referencing data types
74 class HLADataTypeReference : public HLADataType {
75 public:
76     HLADataTypeReference(const SGSharedPtr<HLADataType>& dataType) :
77         HLADataType(dataType->getName(), dataType->getAlignment()),
78         _dataType(dataType)
79     { }
80     virtual ~HLADataTypeReference();
81
82     SGSharedPtr<const HLADataType> getDataType() const
83     { return _dataType.lock(); }
84
85     virtual void accept(HLADataTypeVisitor& visitor) const;
86     virtual const HLADataTypeReference* toDataTypeReference() const;
87
88 private:
89     SGWeakPtr<const HLADataType> _dataType;
90 };
91
92 } // namespace simgear
93
94 #endif