1 // Copyright (C) 2009 - 2010 Mathias Froehlich - Mathias.Froehlich@web.de
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.
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.
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.
18 #ifndef HLADataType_hxx
19 #define HLADataType_hxx
22 #include <simgear/structure/SGWeakPtr.hxx>
23 #include <simgear/structure/SGWeakReferenced.hxx>
24 #include "RTIData.hxx"
28 class HLADataTypeVisitor;
30 class HLADataTypeReference;
31 class HLABasicDataType;
32 class HLAArrayDataType;
33 class HLAEnumeratedDataType;
34 class HLAFixedRecordDataType;
35 class HLAVariantDataType;
44 class HLADataType : public SGWeakReferenced {
46 virtual ~HLADataType();
48 const std::string& getName() const
51 const std::string& getSemantics() const
52 { return _semantics; }
53 void setSemantics(const std::string& semantics)
54 { _semantics = semantics; }
56 unsigned getAlignment() const
57 { return _alignment; }
59 virtual void accept(HLADataTypeVisitor& visitor) const;
61 virtual const HLADataTypeReference* toDataTypeReference() const;
62 virtual const HLABasicDataType* toBasicDataType() const;
63 virtual const HLAArrayDataType* toArrayDataType() const;
64 virtual const HLAEnumeratedDataType* toEnumeratedDataType() const;
65 virtual const HLAFixedRecordDataType* toFixedRecordDataType() const;
66 virtual const HLAVariantDataType* toVariantDataType() const;
69 HLADataType(const std::string& name, unsigned alignment = 1);
70 void setAlignment(unsigned alignment);
74 std::string _semantics;
78 // Weak reference to a data type. Used to implement self referencing data types
79 class HLADataTypeReference : public HLADataType {
81 HLADataTypeReference(const SGSharedPtr<HLADataType>& dataType) :
82 HLADataType(dataType->getName(), dataType->getAlignment()),
85 virtual ~HLADataTypeReference();
87 SGSharedPtr<const HLADataType> getDataType() const
88 { return _dataType.lock(); }
90 virtual void accept(HLADataTypeVisitor& visitor) const;
91 virtual const HLADataTypeReference* toDataTypeReference() const;
94 SGWeakPtr<const HLADataType> _dataType;
97 } // namespace simgear