X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fhla%2FHLADataType.hxx;h=ad52958b03502eec99bf789185155a4226e85a33;hb=d4310a7f3b27b8403ba1ec030cfd3b4c6c565f24;hp=23fb5070d5ca48ece7040d7d39494bcbe4fcd091;hpb=feab25d0bee2c65a9b5c0a27802fb71c9a1a1190;p=simgear.git diff --git a/simgear/hla/HLADataType.hxx b/simgear/hla/HLADataType.hxx index 23fb5070..ad52958b 100644 --- a/simgear/hla/HLADataType.hxx +++ b/simgear/hla/HLADataType.hxx @@ -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 @@ -22,24 +22,17 @@ #include #include #include "RTIData.hxx" +#include "HLATypes.hxx" namespace simgear { class HLADataTypeVisitor; -class HLADataTypeReference; class HLABasicDataType; class HLAArrayDataType; class HLAEnumeratedDataType; class HLAFixedRecordDataType; -class HLAVariantDataType; - -enum HLAUpdateType { - HLAStaticUpdate, - HLAPeriodicUpdate, - HLAConditionalUpdate, - HLAUndefinedUpdate -}; +class HLAVariantRecordDataType; class HLADataType : public SGWeakReferenced { public: @@ -58,42 +51,35 @@ 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; virtual const HLAFixedRecordDataType* toFixedRecordDataType() const; - virtual const HLAVariantDataType* toVariantDataType() const; + 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(); + + bool getDataElementIndex(HLADataElementIndex& index, const std::string& path, std::string::size_type offset) const; protected: HLADataType(const std::string& name, unsigned alignment = 1); void setAlignment(unsigned alignment); + virtual void _recomputeAlignmentImplementation(); + private: + class _DataElementIndexVisitor; + 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& dataType) : - HLADataType(dataType->getName(), dataType->getAlignment()), - _dataType(dataType) - { } - virtual ~HLADataTypeReference(); - - SGSharedPtr getDataType() const - { return _dataType.lock(); } - - virtual void accept(HLADataTypeVisitor& visitor) const; - virtual const HLADataTypeReference* toDataTypeReference() const; - -private: - SGWeakPtr _dataType; -}; - } // namespace simgear #endif