]> git.mxchange.org Git - simgear.git/blob - simgear/hla/HLADataType.hxx
hla: Use raw pointers for HLAFederate::_insert methods.
[simgear.git] / simgear / hla / HLADataType.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 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 HLABasicDataType;
31 class HLAArrayDataType;
32 class HLAEnumeratedDataType;
33 class HLAFixedRecordDataType;
34 class HLAVariantRecordDataType;
35
36 class HLADataType : public SGWeakReferenced {
37 public:
38     virtual ~HLADataType();
39
40     const std::string& getName() const
41     { return _name; }
42
43     const std::string& getSemantics() const
44     { return _semantics; }
45     void setSemantics(const std::string& semantics)
46     { _semantics = semantics; }
47
48     unsigned getAlignment() const
49     { return _alignment; }
50
51     virtual void accept(HLADataTypeVisitor& visitor) const;
52
53     virtual const HLABasicDataType* toBasicDataType() const;
54     virtual const HLAArrayDataType* toArrayDataType() const;
55     virtual const HLAEnumeratedDataType* toEnumeratedDataType() const;
56     virtual const HLAFixedRecordDataType* toFixedRecordDataType() const;
57     virtual const HLAVariantRecordDataType* toVariantRecordDataType() const;
58
59     /// Recompute the alignment value of this data type.
60     /// Return true if the alignment changed, false otherwise.
61     bool recomputeAlignment();
62     /// Release references to other data types. Since we can have cycles this is
63     /// required for propper feeing of memory.
64     virtual void releaseDataTypeReferences();
65
66 protected:
67     HLADataType(const std::string& name, unsigned alignment = 1);
68     void setAlignment(unsigned alignment);
69
70     virtual void _recomputeAlignmentImplementation();
71
72 private:
73     std::string _name;
74     std::string _semantics;
75     unsigned _alignment;
76 };
77
78 } // namespace simgear
79
80 #endif