]> git.mxchange.org Git - simgear.git/blobdiff - simgear/hla/HLADataType.hxx
Move vector property templates to separate header file.
[simgear.git] / simgear / hla / HLADataType.hxx
index c792edd2c46ffe861b55437a93cda7a84f2fafa2..e728fa8c6a6bc4d1bdbec5f9ec799a5042951186 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 - 2010  Mathias Froehlich - Mathias.Froehlich@web.de
+// Copyright (C) 2009 - 2012  Mathias Froehlich - Mathias.Froehlich@web.de
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Library General Public
@@ -27,7 +27,6 @@ namespace simgear {
 
 class HLADataTypeVisitor;
 
-class HLADataTypeReference;
 class HLABasicDataType;
 class HLAArrayDataType;
 class HLAEnumeratedDataType;
@@ -51,7 +50,6 @@ public:
 
     virtual void accept(HLADataTypeVisitor& visitor) const;
 
-    virtual const HLADataTypeReference* toDataTypeReference() const;
     virtual const HLABasicDataType* toBasicDataType() const;
     virtual const HLAArrayDataType* toArrayDataType() const;
     virtual const HLAEnumeratedDataType* toEnumeratedDataType() const;
@@ -60,35 +58,25 @@ public:
     const HLAVariantRecordDataType* toVariantDataType() const { return toVariantRecordDataType(); }
     virtual const HLAVariantRecordDataType* toVariantRecordDataType() const;
 
+    /// Recompute the alignment value of this data type.
+    /// Return true if the alignment changed, false otherwise.
+    bool recomputeAlignment();
+    /// Release references to other data types. Since we can have cycles this is
+    /// required for propper feeing of memory.
+    virtual void releaseDataTypeReferences();
+
 protected:
     HLADataType(const std::string& name, unsigned alignment = 1);
     void setAlignment(unsigned alignment);
 
+    virtual void _recomputeAlignmentImplementation();
+
 private:
     std::string _name;
     std::string _semantics;
     unsigned _alignment;
 };
 
-// Weak reference to a data type. Used to implement self referencing data types
-class HLADataTypeReference : public HLADataType {
-public:
-    HLADataTypeReference(const SGSharedPtr<HLADataType>& dataType) :
-        HLADataType(dataType->getName(), dataType->getAlignment()),
-        _dataType(dataType)
-    { }
-    virtual ~HLADataTypeReference();
-
-    SGSharedPtr<const HLADataType> getDataType() const
-    { return _dataType.lock(); }
-
-    virtual void accept(HLADataTypeVisitor& visitor) const;
-    virtual const HLADataTypeReference* toDataTypeReference() const;
-
-private:
-    SGWeakPtr<const HLADataType> _dataType;
-};
-
 } // namespace simgear
 
 #endif