Rename to the true name that is used in the standard.
HLARawDataElement.hxx
HLAVariantDataElement.hxx
HLAVariantDataType.hxx
+ HLAVariantRecordDataElement.hxx
+ HLAVariantRecordDataType.hxx
)
set(HLA_SOURCES
HLAOMTXmlVisitor.cxx
HLAPropertyDataElement.cxx
HLARawDataElement.cxx
- HLAVariantDataElement.cxx
- HLAVariantDataType.cxx
+ HLAVariantRecordDataElement.cxx
+ HLAVariantRecordDataType.cxx
)
simgear_component(hla hla "${HLA_SOURCES}" "${HLA_HEADERS}")
-// 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
SG_LOG(SG_NETWORK, SG_WARN, "HLAVariantArrayDataType: unable to set data type, dataType is not an array data type!");
return false;
}
- const HLAVariantDataType* variantDataType = arrayDataType->getElementDataType()->toVariantDataType();
- if (!variantDataType) {
+ const HLAVariantRecordDataType* variantRecordDataType = arrayDataType->getElementDataType()->toVariantRecordDataType();
+ if (!variantRecordDataType) {
SG_LOG(SG_NETWORK, SG_WARN, "HLAVariantArrayDataType: unable to set data type: arrayDataTypes element data type is no a variant data type!");
return false;
}
bool
HLAVariantArrayDataElement::decodeElement(HLADecodeStream& stream, unsigned i)
{
- HLAVariantDataElement* dataElement = getElement(i);
+ HLAVariantRecordDataElement* dataElement = getElement(i);
if (!dataElement)
return false;
return dataElement->decode(stream);
return dataElement->encode(stream);
}
-const HLAVariantDataElement*
+const HLAVariantRecordDataElement*
HLAVariantArrayDataElement::getElement(unsigned index) const
{
if (_elementVector.size() <= index)
return _elementVector[index].get();
}
-HLAVariantDataElement*
+HLAVariantRecordDataElement*
HLAVariantArrayDataElement::getElement(unsigned index)
{
if (_elementVector.size() <= index)
return _elementVector[index].get();
}
-HLAVariantDataElement*
+HLAVariantRecordDataElement*
HLAVariantArrayDataElement::getOrCreateElement(unsigned index)
{
if (_elementVector.size() <= index)
}
void
-HLAVariantArrayDataElement::setElement(unsigned index, HLAVariantDataElement* value)
+HLAVariantArrayDataElement::setElement(unsigned index, HLAVariantRecordDataElement* value)
{
unsigned oldSize = _elementVector.size();
if (oldSize <= index) {
return _alternativeDataElementFactory.get();
}
-HLAVariantDataElement*
+HLAVariantRecordDataElement*
HLAVariantArrayDataElement::newElement()
{
const HLAArrayDataType* arrayDataType = getDataType();
const HLADataType* elementDataType = arrayDataType->getElementDataType();
if (!elementDataType)
return 0;
- const HLAVariantDataType* variantDataType = elementDataType->toVariantDataType();
- if (!variantDataType)
+ const HLAVariantRecordDataType* variantRecordDataType = elementDataType->toVariantRecordDataType();
+ if (!variantRecordDataType)
return 0;
- HLAVariantDataElement* variantDataElement = new HLAVariantDataElement(variantDataType);
- variantDataElement->setDataElementFactory(_alternativeDataElementFactory.get());
- return variantDataElement;
+ HLAVariantRecordDataElement* variantRecordDataElement = new HLAVariantRecordDataElement(variantRecordDataType);
+ variantRecordDataElement->setDataElementFactory(_alternativeDataElementFactory.get());
+ return variantRecordDataElement;
}
}
-// 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
#include <simgear/math/SGMath.hxx>
#include "HLAArrayDataType.hxx"
#include "HLADataElement.hxx"
-#include "HLAVariantDataElement.hxx"
+#include "HLAVariantRecordDataElement.hxx"
#include "HLADataTypeVisitor.hxx"
namespace simgear {
virtual unsigned getNumElements() const;
virtual bool encodeElement(HLAEncodeStream& stream, unsigned i) const;
- const HLAVariantDataElement* getElement(unsigned index) const;
- HLAVariantDataElement* getElement(unsigned index);
- HLAVariantDataElement* getOrCreateElement(unsigned index);
- void setElement(unsigned index, HLAVariantDataElement* value);
+ const HLAVariantRecordDataElement* getElement(unsigned index) const;
+ HLAVariantRecordDataElement* getElement(unsigned index);
+ HLAVariantRecordDataElement* getOrCreateElement(unsigned index);
+ void setElement(unsigned index, HLAVariantRecordDataElement* value);
- typedef HLAVariantDataElement::DataElementFactory AlternativeDataElementFactory;
+ typedef HLAVariantRecordDataElement::DataElementFactory AlternativeDataElementFactory;
void setAlternativeDataElementFactory(AlternativeDataElementFactory* alternativeDataElementFactory);
AlternativeDataElementFactory* getAlternativeDataElementFactory();
private:
- HLAVariantDataElement* newElement();
+ HLAVariantRecordDataElement* newElement();
- typedef std::vector<SGSharedPtr<HLAVariantDataElement> > ElementVector;
+ typedef std::vector<SGSharedPtr<HLAVariantRecordDataElement> > ElementVector;
ElementVector _elementVector;
SGSharedPtr<AlternativeDataElementFactory> _alternativeDataElementFactory;
-// Copyright (C) 2009 - 2011 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
class HLAAbstractEnumeratedDataElement;
class HLAAbstractFixedRecordDataElement;
class HLAAbstractArrayDataElement;
-class HLAAbstractVariantDataElement;
+class HLAAbstractVariantRecordDataElement;
class HLADataElementVisitor {
public:
virtual void apply(HLAAbstractEnumeratedDataElement&);
virtual void apply(HLAAbstractArrayDataElement&);
virtual void apply(HLAAbstractFixedRecordDataElement&);
- virtual void apply(HLAAbstractVariantDataElement&);
+ virtual void apply(HLAAbstractVariantRecordDataElement&);
};
class HLAConstDataElementVisitor {
virtual void apply(const HLAAbstractEnumeratedDataElement&);
virtual void apply(const HLAAbstractArrayDataElement&);
virtual void apply(const HLAAbstractFixedRecordDataElement&);
- virtual void apply(const HLAAbstractVariantDataElement&);
+ virtual void apply(const HLAAbstractVariantRecordDataElement&);
};
}
-// 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
return 0;
}
-const HLAVariantDataType*
-HLADataType::toVariantDataType() const
+const HLAVariantRecordDataType*
+HLADataType::toVariantRecordDataType() const
{
return 0;
}
class HLAArrayDataType;
class HLAEnumeratedDataType;
class HLAFixedRecordDataType;
-class HLAVariantDataType;
+class HLAVariantRecordDataType;
enum HLAUpdateType {
HLAStaticUpdate,
virtual const HLAArrayDataType* toArrayDataType() const;
virtual const HLAEnumeratedDataType* toEnumeratedDataType() const;
virtual const HLAFixedRecordDataType* toFixedRecordDataType() const;
- virtual const HLAVariantDataType* toVariantDataType() const;
+ /// deprecated
+ const HLAVariantRecordDataType* toVariantDataType() const { return toVariantRecordDataType(); }
+ virtual const HLAVariantRecordDataType* toVariantRecordDataType() const;
protected:
HLADataType(const std::string& name, unsigned alignment = 1);
-// 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
#include "HLADataTypeVisitor.hxx"
#include "HLAEnumeratedDataElement.hxx"
#include "HLAFixedRecordDataElement.hxx"
-#include "HLAVariantDataElement.hxx"
+#include "HLAVariantRecordDataElement.hxx"
namespace simgear {
_dataElement = recordDataElement;
}
-class HLADataElementFactoryVisitor::VariantDataElementFactory : public HLAVariantDataElement::DataElementFactory {
+class HLADataElementFactoryVisitor::VariantRecordDataElementFactory : public HLAVariantRecordDataElement::DataElementFactory {
public:
- virtual HLADataElement* createElement(const HLAVariantDataElement& element, unsigned index)
+ virtual HLADataElement* createElement(const HLAVariantRecordDataElement& element, unsigned index)
{
- const HLAVariantDataType* dataType = element.getDataType();
+ const HLAVariantRecordDataType* dataType = element.getDataType();
if (!dataType)
return 0;
const HLADataType* alternativeDataType = element.getAlternativeDataType();
};
void
-HLADataElementFactoryVisitor::apply(const HLAVariantDataType& dataType)
+HLADataElementFactoryVisitor::apply(const HLAVariantRecordDataType& dataType)
{
- SGSharedPtr<HLAVariantDataElement> variantDataElement;
- variantDataElement = new HLAVariantDataElement(&dataType);
- variantDataElement->setDataElementFactory(new VariantDataElementFactory);
- _dataElement = variantDataElement;
+ SGSharedPtr<HLAVariantRecordDataElement> variantRecordDataElement;
+ variantRecordDataElement = new HLAVariantRecordDataElement(&dataType);
+ variantRecordDataElement->setDataElementFactory(new VariantRecordDataElementFactory);
+ _dataElement = variantRecordDataElement;
}
} // namespace simgear
-// 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
#include "HLADataElement.hxx"
#include "HLAEnumeratedDataType.hxx"
#include "HLAFixedRecordDataType.hxx"
-#include "HLAVariantDataType.hxx"
+#include "HLAVariantRecordDataType.hxx"
namespace simgear {
virtual void apply(const HLAFixedRecordDataType& dataType)
{ apply(static_cast<const HLADataType&>(dataType)); }
- virtual void apply(const HLAVariantDataType& dataType)
+ virtual void apply(const HLAVariantRecordDataType& dataType)
{ apply(static_cast<const HLADataType&>(dataType)); }
};
}
}
- virtual void apply(const HLAVariantDataType& dataType)
+ virtual void apply(const HLAVariantRecordDataType& dataType)
{ assert(0); }
protected:
dataType.getFieldDataType(i)->accept(*this);
}
- virtual void apply(const HLAVariantDataType& dataType) { assert(0); }
+ virtual void apply(const HLAVariantRecordDataType& dataType) { assert(0); }
protected:
HLADecodeStream& _stream;
dataType.getFieldDataType(i)->accept(*this);
}
- virtual void apply(const HLAVariantDataType& dataType) { assert(0); }
+ virtual void apply(const HLAVariantRecordDataType& dataType) { assert(0); }
protected:
HLAEncodeStream& _stream;
HLADataTypeDecodeVisitor::apply(dataType);
}
- virtual void apply(const HLAVariantDataType& dataType)
+ virtual void apply(const HLAVariantRecordDataType& dataType)
{
SG_LOG(SG_NETWORK, SG_WARN, "Unexpected HLADataType while decodeing scalar value");
HLADataTypeDecodeVisitor::apply(dataType);
HLADataTypeEncodeVisitor::apply(dataType);
}
- virtual void apply(const HLAVariantDataType& dataType)
+ virtual void apply(const HLAVariantRecordDataType& dataType)
{
SG_LOG(SG_NETWORK, SG_WARN, "Unexpected HLADataType while writing scalar value");
HLADataTypeEncodeVisitor::apply(dataType);
HLADataTypeDecodeVisitor::apply(dataType);
}
- virtual void apply(const HLAVariantDataType& dataType)
+ virtual void apply(const HLAVariantRecordDataType& dataType)
{
SG_LOG(SG_NETWORK, SG_WARN, "Unexpected HLADataType while decodeing a fixed record value");
HLADataTypeDecodeVisitor::apply(dataType);
HLADataTypeEncodeVisitor::apply(dataType);
}
- virtual void apply(const HLAVariantDataType& dataType)
+ virtual void apply(const HLAVariantRecordDataType& dataType)
{
SG_LOG(SG_NETWORK, SG_WARN, "Unexpected HLADataType while writing a fixed record value");
HLADataTypeEncodeVisitor::apply(dataType);
virtual void apply(const HLAFixedRecordDataType& dataType);
- virtual void apply(const HLAVariantDataType& dataType);
+ virtual void apply(const HLAVariantRecordDataType& dataType);
HLADataElement* getDataElement()
{ return _dataElement.release(); }
protected:
class ArrayDataElementFactory;
- class VariantDataElementFactory;
+ class VariantRecordDataElementFactory;
SGSharedPtr<HLADataElement> _dataElement;
};
-// Copyright (C) 2009 - 2011 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
#include "HLADataTypeVisitor.hxx"
#include "HLAEnumeratedDataType.hxx"
#include "HLAFixedRecordDataType.hxx"
-#include "HLAVariantDataType.hxx"
+#include "HLAVariantRecordDataType.hxx"
namespace simgear {
if (dataType.valid())
return dataType;
- dataType = getVariantDataType(dataTypeName, dataTypeMap);
+ dataType = getVariantRecordDataType(dataTypeName, dataTypeMap);
if (dataType.valid())
return dataType;
return dataType;
}
-SGSharedPtr<HLAVariantDataType>
-HLAOMTXmlVisitor::getVariantDataType(const std::string& dataTypeName, HLAOMTXmlVisitor::StringDataTypeMap& dataTypeMap) const
+SGSharedPtr<HLAVariantRecordDataType>
+HLAOMTXmlVisitor::getVariantRecordDataType(const std::string& dataTypeName, HLAOMTXmlVisitor::StringDataTypeMap& dataTypeMap) const
{
VariantRecordDataMap::const_iterator i = _variantRecordDataMap.find(dataTypeName);
if (i == _variantRecordDataMap.end())
return 0;
- SGSharedPtr<HLAVariantDataType> dataType = new HLAVariantDataType(dataTypeName);
+ SGSharedPtr<HLAVariantRecordDataType> dataType = new HLAVariantRecordDataType(dataTypeName);
dataTypeMap[dataTypeName] = dataType;
SGSharedPtr<HLAEnumeratedDataType> enumeratedDataType = getEnumeratedDataType(i->second._dataType);
-// 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
SGSharedPtr<HLAEnumeratedDataType> getEnumeratedDataType(const std::string& dataTypeName) const;
SGSharedPtr<HLADataType> getArrayDataType(const std::string& dataTypeName, StringDataTypeMap& dataTypeMap) const;
SGSharedPtr<HLAFixedRecordDataType> getFixedRecordDataType(const std::string& dataTypeName, StringDataTypeMap& dataTypeMap) const;
- SGSharedPtr<HLAVariantDataType> getVariantDataType(const std::string& dataTypeName, StringDataTypeMap& dataTypeMap) const;
+ SGSharedPtr<HLAVariantRecordDataType> getVariantRecordDataType(const std::string& dataTypeName, StringDataTypeMap& dataTypeMap) const;
enum Mode {
UnknownMode,
-// 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
#include "HLAEnumeratedDataElement.hxx"
#include "HLAFixedRecordDataElement.hxx"
#include "HLAObjectClass.hxx"
-#include "HLAVariantDataElement.hxx"
+#include "HLAVariantRecordDataElement.hxx"
#include "RTIObjectClass.hxx"
#include "RTIObjectInstance.hxx"
_dataElement = recordDataElement;
}
- class VariantDataElementFactory : public HLAVariantDataElement::DataElementFactory {
+ class VariantRecordDataElementFactory : public HLAVariantRecordDataElement::DataElementFactory {
public:
- VariantDataElementFactory(const HLADataElement::Path& path, const HLAPathElementMap& pathElementMap) :
+ VariantRecordDataElementFactory(const HLADataElement::Path& path, const HLAPathElementMap& pathElementMap) :
_path(path)
{
for (HLAPathElementMap::const_iterator i = pathElementMap.lower_bound(path);
_pathElementMap.insert(*i);
}
}
- virtual HLADataElement* createElement(const HLAVariantDataElement& element, unsigned index)
+ virtual HLADataElement* createElement(const HLAVariantRecordDataElement& element, unsigned index)
{
- const HLAVariantDataType* dataType = element.getDataType();
+ const HLAVariantRecordDataType* dataType = element.getDataType();
if (!dataType)
return 0;
const HLADataType* alternativeDataType = element.getAlternativeDataType();
HLAPathElementMap _pathElementMap;
};
- virtual void apply(const HLAVariantDataType& dataType)
+ virtual void apply(const HLAVariantRecordDataType& dataType)
{
_dataElement = createDataElement(_path, dataType);
if (_dataElement.valid())
return;
- SGSharedPtr<HLAVariantDataElement> variantDataElement;
- variantDataElement = new HLAVariantDataElement(&dataType);
- variantDataElement->setDataElementFactory(new VariantDataElementFactory(_path, _pathElementMap));
+ SGSharedPtr<HLAVariantRecordDataElement> variantRecordDataElement;
+ variantRecordDataElement = new HLAVariantRecordDataElement(&dataType);
+ variantRecordDataElement->setDataElementFactory(new VariantRecordDataElementFactory(_path, _pathElementMap));
- _dataElement = variantDataElement;
+ _dataElement = variantRecordDataElement;
}
private:
-// Copyright (C) 2009 - 2011 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
#include "HLADataElementVisitor.hxx"
#include "HLADataTypeVisitor.hxx"
#include "HLAFixedRecordDataElement.hxx"
-#include "HLAVariantDataElement.hxx"
+#include "HLAVariantRecordDataElement.hxx"
namespace simgear {
_dataElement = recordDataElement;
}
- class VariantDataElementFactory : public HLAVariantDataElement::DataElementFactory {
+ class VariantRecordDataElementFactory : public HLAVariantRecordDataElement::DataElementFactory {
public:
- VariantDataElementFactory(SGPropertyNode* propertyNode) :
+ VariantRecordDataElementFactory(SGPropertyNode* propertyNode) :
_propertyNode(propertyNode)
{ }
- virtual HLADataElement* createElement(const HLAVariantDataElement& element, unsigned index)
+ virtual HLADataElement* createElement(const HLAVariantRecordDataElement& element, unsigned index)
{
- const HLAVariantDataType* dataType = element.getDataType();
+ const HLAVariantRecordDataType* dataType = element.getDataType();
if (!dataType)
return 0;
const HLADataType* alternativeDataType = element.getAlternativeDataType();
SGSharedPtr<SGPropertyNode> _propertyNode;
};
- virtual void apply(const HLAVariantDataType& dataType)
+ virtual void apply(const HLAVariantRecordDataType& dataType)
{
- SGSharedPtr<HLAVariantDataElement> variantDataElement;
- variantDataElement = new HLAVariantDataElement(&dataType);
- variantDataElement->setDataElementFactory(new VariantDataElementFactory(_propertyNode.get()));
- _dataElement = variantDataElement;
+ SGSharedPtr<HLAVariantRecordDataElement> variantRecordDataElement;
+ variantRecordDataElement = new HLAVariantRecordDataElement(&dataType);
+ variantRecordDataElement->setDataElementFactory(new VariantRecordDataElementFactory(_propertyNode.get()));
+ _dataElement = variantRecordDataElement;
}
HLADataElement* getDataElement()
+++ /dev/null
-// Copyright (C) 2009 - 2010 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
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-
-#include "HLAVariantDataElement.hxx"
-
-#include <simgear/debug/logstream.hxx>
-
-#include "HLADataElementVisitor.hxx"
-
-namespace simgear {
-
-HLAAbstractVariantDataElement::HLAAbstractVariantDataElement(const HLAVariantDataType* dataType) :
- _dataType(dataType)
-{
-}
-
-HLAAbstractVariantDataElement::~HLAAbstractVariantDataElement()
-{
-}
-
-void
-HLAAbstractVariantDataElement::accept(HLADataElementVisitor& visitor)
-{
- visitor.apply(*this);
-}
-
-void
-HLAAbstractVariantDataElement::accept(HLAConstDataElementVisitor& visitor) const
-{
- visitor.apply(*this);
-}
-
-bool
-HLAAbstractVariantDataElement::decode(HLADecodeStream& stream)
-{
- if (!_dataType.valid())
- return false;
- return _dataType->decode(stream, *this);
-}
-
-bool
-HLAAbstractVariantDataElement::encode(HLAEncodeStream& stream) const
-{
- if (!_dataType.valid())
- return false;
- return _dataType->encode(stream, *this);
-}
-
-const HLAVariantDataType*
-HLAAbstractVariantDataElement::getDataType() const
-{
- return _dataType.get();
-}
-
-bool
-HLAAbstractVariantDataElement::setDataType(const HLADataType* dataType)
-{
- const HLAVariantDataType* variantDataType = dataType->toVariantDataType();
- if (!variantDataType) {
- SG_LOG(SG_NETWORK, SG_WARN, "HLAVariantDataType: unable to set data type!");
- return false;
- }
- setDataType(variantDataType);
- return true;
-}
-
-void
-HLAAbstractVariantDataElement::setDataType(const HLAVariantDataType* dataType)
-{
- _dataType = dataType;
-}
-
-std::string
-HLAAbstractVariantDataElement::getAlternativeName() const
-{
- if (!_dataType.valid())
- return std::string();
- return _dataType->getAlternativeName(getAlternativeIndex());
-}
-
-const HLADataType*
-HLAAbstractVariantDataElement::getAlternativeDataType() const
-{
- if (!_dataType.valid())
- return 0;
- return _dataType->getAlternativeDataType(getAlternativeIndex());
-}
-
-
-HLAVariantDataElement::DataElementFactory::~DataElementFactory()
-{
-}
-
-HLAVariantDataElement::HLAVariantDataElement(const HLAVariantDataType* dataType) :
- HLAAbstractVariantDataElement(dataType),
- _alternativeIndex(~0u)
-{
-}
-
-HLAVariantDataElement::~HLAVariantDataElement()
-{
-}
-
-bool
-HLAVariantDataElement::setAlternativeIndex(unsigned index)
-{
- if (_alternativeIndex == index)
- return true;
- SGSharedPtr<HLADataElement> dataElement = newElement(index);
- if (!dataElement.valid())
- return false;
- _dataElement.swap(dataElement);
- _alternativeIndex = index;
- return true;
-}
-
-bool
-HLAVariantDataElement::decodeAlternative(HLADecodeStream& stream)
-{
- return _dataElement->decode(stream);
-}
-
-unsigned
-HLAVariantDataElement::getAlternativeIndex() const
-{
- return _alternativeIndex;
-}
-
-bool
-HLAVariantDataElement::encodeAlternative(HLAEncodeStream& stream) const
-{
- return _dataElement->encode(stream);
-}
-
-void
-HLAVariantDataElement::setDataElementFactory(HLAVariantDataElement::DataElementFactory* dataElementFactory)
-{
- _dataElementFactory = dataElementFactory;
-}
-
-HLAVariantDataElement::DataElementFactory*
-HLAVariantDataElement::getDataElementFactory()
-{
- return _dataElementFactory;
-}
-
-HLADataElement*
-HLAVariantDataElement::newElement(unsigned index)
-{
- if (!_dataElementFactory.valid())
- return 0;
- return _dataElementFactory->createElement(*this, index);
-}
-
-}
-// 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
#ifndef HLAVariantDataElement_hxx
#define HLAVariantDataElement_hxx
-#include <string>
-#include <simgear/structure/SGSharedPtr.hxx>
-#include "HLADataElement.hxx"
#include "HLAVariantDataType.hxx"
+#include "HLAVariantRecordDataElement.hxx"
namespace simgear {
-class HLAAbstractVariantDataElement : public HLADataElement {
-public:
- HLAAbstractVariantDataElement(const HLAVariantDataType* dataType);
- virtual ~HLAAbstractVariantDataElement();
-
- virtual void accept(HLADataElementVisitor& visitor);
- virtual void accept(HLAConstDataElementVisitor& visitor) const;
-
- virtual bool decode(HLADecodeStream& stream);
- virtual bool encode(HLAEncodeStream& stream) const;
-
- virtual const HLAVariantDataType* getDataType() const;
- virtual bool setDataType(const HLADataType* dataType);
- void setDataType(const HLAVariantDataType* dataType);
-
- std::string getAlternativeName() const;
- const HLADataType* getAlternativeDataType() const;
-
- virtual bool setAlternativeIndex(unsigned index) = 0;
- virtual bool decodeAlternative(HLADecodeStream& stream) = 0;
- virtual unsigned getAlternativeIndex() const = 0;
- virtual bool encodeAlternative(HLAEncodeStream& stream) const = 0;
-
-private:
- SGSharedPtr<const HLAVariantDataType> _dataType;
-};
-
-class HLAVariantDataElement : public HLAAbstractVariantDataElement {
-public:
- HLAVariantDataElement(const HLAVariantDataType* dataType);
- virtual ~HLAVariantDataElement();
-
- virtual bool setAlternativeIndex(unsigned index);
- virtual bool decodeAlternative(HLADecodeStream& stream);
- virtual unsigned getAlternativeIndex() const;
- virtual bool encodeAlternative(HLAEncodeStream& stream) const;
-
- class DataElementFactory : public SGReferenced {
- public:
- virtual ~DataElementFactory();
- virtual HLADataElement* createElement(const HLAVariantDataElement&, unsigned) = 0;
- };
-
- void setDataElementFactory(DataElementFactory* dataElementFactory);
- DataElementFactory* getDataElementFactory();
-
-private:
- HLADataElement* newElement(unsigned index);
-
- SGSharedPtr<HLADataElement> _dataElement;
- unsigned _alternativeIndex;
-
- SGSharedPtr<DataElementFactory> _dataElementFactory;
-};
+typedef HLAAbstractVariantRecordDataElement HLAAbstractVariantDataElement;
+typedef HLAVariantRecordDataElement HLAVariantDataElement;
}
+++ /dev/null
-// Copyright (C) 2009 - 2010 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
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-
-#include "HLAVariantDataType.hxx"
-
-#include "HLADataTypeVisitor.hxx"
-#include "HLAVariantDataElement.hxx"
-
-namespace simgear {
-
-HLAVariantDataType::HLAVariantDataType(const std::string& name) :
- HLADataType(name)
-{
-}
-
-HLAVariantDataType::~HLAVariantDataType()
-{
-}
-
-void
-HLAVariantDataType::accept(HLADataTypeVisitor& visitor) const
-{
- visitor.apply(*this);
-}
-
-const HLAVariantDataType*
-HLAVariantDataType::toVariantDataType() const
-{
- return this;
-}
-
-bool
-HLAVariantDataType::decode(HLADecodeStream& stream, HLAAbstractVariantDataElement& value) const
-{
- if (!stream.alignOffsetForSize(getAlignment()))
- return false;
- if (!_enumeratedDataType.valid())
- return false;
- unsigned index = ~0u;
- if (!_enumeratedDataType->decode(stream, index))
- return false;
- if (!value.setAlternativeIndex(index))
- return false;
- if (!value.decodeAlternative(stream))
- return false;
- return true;
-}
-
-bool
-HLAVariantDataType::encode(HLAEncodeStream& stream, const HLAAbstractVariantDataElement& value) const
-{
- if (!stream.alignOffsetForSize(getAlignment()))
- return false;
- if (!_enumeratedDataType.valid())
- return false;
- unsigned index = value.getAlternativeIndex();
- if (!_enumeratedDataType->encode(stream, index))
- return false;
- if (!value.encodeAlternative(stream))
- return false;
- return true;
-}
-
-void
-HLAVariantDataType::setEnumeratedDataType(HLAEnumeratedDataType* dataType)
-{
- _enumeratedDataType = dataType;
-}
-
-bool
-HLAVariantDataType::addAlternative(const std::string& name, const std::string& enumerator,
- const HLADataType* dataType, const std::string& semantics)
-{
- if (!_enumeratedDataType.valid())
- return false;
- unsigned index = _enumeratedDataType->getIndex(enumerator);
- if (_enumeratedDataType->getNumEnumerators() <= index)
- return false;
- _alternativeList.resize(_enumeratedDataType->getNumEnumerators());
- _alternativeList[index]._name = name;
- _alternativeList[index]._dataType = dataType;
- _alternativeList[index]._semantics = semantics;
- setAlignment(SGMisc<unsigned>::max(getAlignment(), dataType->getAlignment()));
- return true;
-}
-
-} // namespace simgear
-// 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
#ifndef HLAVariantDataType_hxx
#define HLAVariantDataType_hxx
-#include <string>
-#include <vector>
-#include "simgear/structure/SGSharedPtr.hxx"
-#include "HLADataType.hxx"
-#include "HLAEnumeratedDataType.hxx"
+#include "HLAVariantRecordDataType.hxx"
namespace simgear {
-class HLAAbstractVariantDataElement;
-
-class HLAVariantDataType : public HLADataType {
-public:
- HLAVariantDataType(const std::string& name = "HLAVariantDataType");
- virtual ~HLAVariantDataType();
-
- virtual void accept(HLADataTypeVisitor& visitor) const;
-
- virtual const HLAVariantDataType* toVariantDataType() const;
-
- virtual bool decode(HLADecodeStream& stream, HLAAbstractVariantDataElement& value) const;
- virtual bool encode(HLAEncodeStream& stream, const HLAAbstractVariantDataElement& value) const;
-
- const HLAEnumeratedDataType* getEnumeratedDataType() const
- { return _enumeratedDataType.get(); }
- void setEnumeratedDataType(HLAEnumeratedDataType* dataType);
-
- bool addAlternative(const std::string& name, const std::string& enumerator,
- const HLADataType* dataType, const std::string& semantics);
-
- unsigned getNumAlternatives() const
- { return _alternativeList.size(); }
-
- unsigned getAlternativeIndex(const std::string& enumerator) const
- {
- if (!_enumeratedDataType.valid())
- return ~unsigned(0);
- return _enumeratedDataType->getIndex(enumerator);
- }
-
- const HLADataType* getAlternativeDataType(unsigned index) const
- {
- if (_alternativeList.size() <= index)
- return 0;
- return _alternativeList[index]._dataType.get();
- }
- const HLADataType* getAlternativeDataType(const std::string& enumerator) const
- { return getAlternativeDataType(getAlternativeIndex(enumerator)); }
-
- std::string getAlternativeName(unsigned index) const
- {
- if (_alternativeList.size() <= index)
- return std::string();
- return _alternativeList[index]._name;
- }
- std::string getAlternativeName(const std::string& enumerator) const
- { return getAlternativeName(getAlternativeIndex(enumerator)); }
-
- std::string getAlternativeSemantics(unsigned index) const
- {
- if (_alternativeList.size() <= index)
- return std::string();
- return _alternativeList[index]._semantics;
- }
- std::string getAlternativeSemantics(const std::string& enumerator) const
- { return getAlternativeSemantics(getAlternativeIndex(enumerator)); }
-
-private:
- SGSharedPtr<HLAEnumeratedDataType> _enumeratedDataType;
-
- struct Alternative {
- std::string _name;
- SGSharedPtr<const HLADataType> _dataType;
- std::string _semantics;
- };
-
- typedef std::vector<Alternative> AlternativeList;
- AlternativeList _alternativeList;
-};
+typedef HLAVariantRecordDataType HLAVariantDataType;
} // namespace simgear
--- /dev/null
+// 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
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "HLAVariantRecordDataElement.hxx"
+
+#include <simgear/debug/logstream.hxx>
+
+#include "HLADataElementVisitor.hxx"
+
+namespace simgear {
+
+HLAAbstractVariantRecordDataElement::HLAAbstractVariantRecordDataElement(const HLAVariantRecordDataType* dataType) :
+ _dataType(dataType)
+{
+}
+
+HLAAbstractVariantRecordDataElement::~HLAAbstractVariantRecordDataElement()
+{
+}
+
+void
+HLAAbstractVariantRecordDataElement::accept(HLADataElementVisitor& visitor)
+{
+ visitor.apply(*this);
+}
+
+void
+HLAAbstractVariantRecordDataElement::accept(HLAConstDataElementVisitor& visitor) const
+{
+ visitor.apply(*this);
+}
+
+bool
+HLAAbstractVariantRecordDataElement::decode(HLADecodeStream& stream)
+{
+ if (!_dataType.valid())
+ return false;
+ return _dataType->decode(stream, *this);
+}
+
+bool
+HLAAbstractVariantRecordDataElement::encode(HLAEncodeStream& stream) const
+{
+ if (!_dataType.valid())
+ return false;
+ return _dataType->encode(stream, *this);
+}
+
+const HLAVariantRecordDataType*
+HLAAbstractVariantRecordDataElement::getDataType() const
+{
+ return _dataType.get();
+}
+
+bool
+HLAAbstractVariantRecordDataElement::setDataType(const HLADataType* dataType)
+{
+ const HLAVariantRecordDataType* variantRecordDataType = dataType->toVariantRecordDataType();
+ if (!variantRecordDataType) {
+ SG_LOG(SG_NETWORK, SG_WARN, "HLAVariantRecordDataType: unable to set data type!");
+ return false;
+ }
+ setDataType(variantRecordDataType);
+ return true;
+}
+
+void
+HLAAbstractVariantRecordDataElement::setDataType(const HLAVariantRecordDataType* dataType)
+{
+ _dataType = dataType;
+}
+
+std::string
+HLAAbstractVariantRecordDataElement::getAlternativeName() const
+{
+ if (!_dataType.valid())
+ return std::string();
+ return _dataType->getAlternativeName(getAlternativeIndex());
+}
+
+const HLADataType*
+HLAAbstractVariantRecordDataElement::getAlternativeDataType() const
+{
+ if (!_dataType.valid())
+ return 0;
+ return _dataType->getAlternativeDataType(getAlternativeIndex());
+}
+
+
+HLAVariantRecordDataElement::DataElementFactory::~DataElementFactory()
+{
+}
+
+HLAVariantRecordDataElement::HLAVariantRecordDataElement(const HLAVariantRecordDataType* dataType) :
+ HLAAbstractVariantRecordDataElement(dataType),
+ _alternativeIndex(~0u)
+{
+}
+
+HLAVariantRecordDataElement::~HLAVariantRecordDataElement()
+{
+}
+
+bool
+HLAVariantRecordDataElement::setAlternativeIndex(unsigned index)
+{
+ if (_alternativeIndex == index)
+ return true;
+ SGSharedPtr<HLADataElement> dataElement = newElement(index);
+ if (!dataElement.valid())
+ return false;
+ _dataElement.swap(dataElement);
+ _alternativeIndex = index;
+ return true;
+}
+
+bool
+HLAVariantRecordDataElement::decodeAlternative(HLADecodeStream& stream)
+{
+ return _dataElement->decode(stream);
+}
+
+unsigned
+HLAVariantRecordDataElement::getAlternativeIndex() const
+{
+ return _alternativeIndex;
+}
+
+bool
+HLAVariantRecordDataElement::encodeAlternative(HLAEncodeStream& stream) const
+{
+ return _dataElement->encode(stream);
+}
+
+void
+HLAVariantRecordDataElement::setDataElementFactory(HLAVariantRecordDataElement::DataElementFactory* dataElementFactory)
+{
+ _dataElementFactory = dataElementFactory;
+}
+
+HLAVariantRecordDataElement::DataElementFactory*
+HLAVariantRecordDataElement::getDataElementFactory()
+{
+ return _dataElementFactory;
+}
+
+HLADataElement*
+HLAVariantRecordDataElement::newElement(unsigned index)
+{
+ if (!_dataElementFactory.valid())
+ return 0;
+ return _dataElementFactory->createElement(*this, index);
+}
+
+}
--- /dev/null
+// 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
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#ifndef HLAVariantRecordDataElement_hxx
+#define HLAVariantRecordDataElement_hxx
+
+#include <string>
+#include <simgear/structure/SGSharedPtr.hxx>
+#include "HLADataElement.hxx"
+#include "HLAVariantRecordDataType.hxx"
+
+namespace simgear {
+
+class HLAAbstractVariantRecordDataElement : public HLADataElement {
+public:
+ HLAAbstractVariantRecordDataElement(const HLAVariantRecordDataType* dataType);
+ virtual ~HLAAbstractVariantRecordDataElement();
+
+ virtual void accept(HLADataElementVisitor& visitor);
+ virtual void accept(HLAConstDataElementVisitor& visitor) const;
+
+ virtual bool decode(HLADecodeStream& stream);
+ virtual bool encode(HLAEncodeStream& stream) const;
+
+ virtual const HLAVariantRecordDataType* getDataType() const;
+ virtual bool setDataType(const HLADataType* dataType);
+ void setDataType(const HLAVariantRecordDataType* dataType);
+
+ std::string getAlternativeName() const;
+ const HLADataType* getAlternativeDataType() const;
+
+ virtual bool setAlternativeIndex(unsigned index) = 0;
+ virtual bool decodeAlternative(HLADecodeStream& stream) = 0;
+ virtual unsigned getAlternativeIndex() const = 0;
+ virtual bool encodeAlternative(HLAEncodeStream& stream) const = 0;
+
+private:
+ SGSharedPtr<const HLAVariantRecordDataType> _dataType;
+};
+
+class HLAVariantRecordDataElement : public HLAAbstractVariantRecordDataElement {
+public:
+ HLAVariantRecordDataElement(const HLAVariantRecordDataType* dataType);
+ virtual ~HLAVariantRecordDataElement();
+
+ virtual bool setAlternativeIndex(unsigned index);
+ virtual bool decodeAlternative(HLADecodeStream& stream);
+ virtual unsigned getAlternativeIndex() const;
+ virtual bool encodeAlternative(HLAEncodeStream& stream) const;
+
+ class DataElementFactory : public SGReferenced {
+ public:
+ virtual ~DataElementFactory();
+ virtual HLADataElement* createElement(const HLAVariantRecordDataElement&, unsigned) = 0;
+ };
+
+ void setDataElementFactory(DataElementFactory* dataElementFactory);
+ DataElementFactory* getDataElementFactory();
+
+private:
+ HLADataElement* newElement(unsigned index);
+
+ SGSharedPtr<HLADataElement> _dataElement;
+ unsigned _alternativeIndex;
+
+ SGSharedPtr<DataElementFactory> _dataElementFactory;
+};
+
+}
+
+#endif
--- /dev/null
+// 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
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "HLAVariantRecordDataType.hxx"
+
+#include "HLADataTypeVisitor.hxx"
+#include "HLAVariantRecordDataElement.hxx"
+
+namespace simgear {
+
+HLAVariantRecordDataType::HLAVariantRecordDataType(const std::string& name) :
+ HLADataType(name)
+{
+}
+
+HLAVariantRecordDataType::~HLAVariantRecordDataType()
+{
+}
+
+void
+HLAVariantRecordDataType::accept(HLADataTypeVisitor& visitor) const
+{
+ visitor.apply(*this);
+}
+
+const HLAVariantRecordDataType*
+HLAVariantRecordDataType::toVariantRecordDataType() const
+{
+ return this;
+}
+
+bool
+HLAVariantRecordDataType::decode(HLADecodeStream& stream, HLAAbstractVariantRecordDataElement& value) const
+{
+ if (!stream.alignOffsetForSize(getAlignment()))
+ return false;
+ if (!_enumeratedDataType.valid())
+ return false;
+ unsigned index = ~0u;
+ if (!_enumeratedDataType->decode(stream, index))
+ return false;
+ if (!value.setAlternativeIndex(index))
+ return false;
+ if (!value.decodeAlternative(stream))
+ return false;
+ return true;
+}
+
+bool
+HLAVariantRecordDataType::encode(HLAEncodeStream& stream, const HLAAbstractVariantRecordDataElement& value) const
+{
+ if (!stream.alignOffsetForSize(getAlignment()))
+ return false;
+ if (!_enumeratedDataType.valid())
+ return false;
+ unsigned index = value.getAlternativeIndex();
+ if (!_enumeratedDataType->encode(stream, index))
+ return false;
+ if (!value.encodeAlternative(stream))
+ return false;
+ return true;
+}
+
+void
+HLAVariantRecordDataType::setEnumeratedDataType(HLAEnumeratedDataType* dataType)
+{
+ _enumeratedDataType = dataType;
+}
+
+bool
+HLAVariantRecordDataType::addAlternative(const std::string& name, const std::string& enumerator,
+ const HLADataType* dataType, const std::string& semantics)
+{
+ if (!_enumeratedDataType.valid())
+ return false;
+ unsigned index = _enumeratedDataType->getIndex(enumerator);
+ if (_enumeratedDataType->getNumEnumerators() <= index)
+ return false;
+ _alternativeList.resize(_enumeratedDataType->getNumEnumerators());
+ _alternativeList[index]._name = name;
+ _alternativeList[index]._dataType = dataType;
+ _alternativeList[index]._semantics = semantics;
+ setAlignment(SGMisc<unsigned>::max(getAlignment(), dataType->getAlignment()));
+ return true;
+}
+
+} // namespace simgear
--- /dev/null
+// 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
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#ifndef HLAVariantRecordDataType_hxx
+#define HLAVariantRecordDataType_hxx
+
+#include <string>
+#include <vector>
+#include "simgear/structure/SGSharedPtr.hxx"
+#include "HLADataType.hxx"
+#include "HLAEnumeratedDataType.hxx"
+
+namespace simgear {
+
+class HLAAbstractVariantRecordDataElement;
+
+class HLAVariantRecordDataType : public HLADataType {
+public:
+ HLAVariantRecordDataType(const std::string& name = "HLAVariantRecordDataType");
+ virtual ~HLAVariantRecordDataType();
+
+ virtual void accept(HLADataTypeVisitor& visitor) const;
+
+ virtual const HLAVariantRecordDataType* toVariantRecordDataType() const;
+
+ virtual bool decode(HLADecodeStream& stream, HLAAbstractVariantRecordDataElement& value) const;
+ virtual bool encode(HLAEncodeStream& stream, const HLAAbstractVariantRecordDataElement& value) const;
+
+ const HLAEnumeratedDataType* getEnumeratedDataType() const
+ { return _enumeratedDataType.get(); }
+ void setEnumeratedDataType(HLAEnumeratedDataType* dataType);
+
+ bool addAlternative(const std::string& name, const std::string& enumerator,
+ const HLADataType* dataType, const std::string& semantics);
+
+ unsigned getNumAlternatives() const
+ { return _alternativeList.size(); }
+
+ unsigned getAlternativeIndex(const std::string& enumerator) const
+ {
+ if (!_enumeratedDataType.valid())
+ return ~unsigned(0);
+ return _enumeratedDataType->getIndex(enumerator);
+ }
+
+ const HLADataType* getAlternativeDataType(unsigned index) const
+ {
+ if (_alternativeList.size() <= index)
+ return 0;
+ return _alternativeList[index]._dataType.get();
+ }
+ const HLADataType* getAlternativeDataType(const std::string& enumerator) const
+ { return getAlternativeDataType(getAlternativeIndex(enumerator)); }
+
+ std::string getAlternativeName(unsigned index) const
+ {
+ if (_alternativeList.size() <= index)
+ return std::string();
+ return _alternativeList[index]._name;
+ }
+ std::string getAlternativeName(const std::string& enumerator) const
+ { return getAlternativeName(getAlternativeIndex(enumerator)); }
+
+ std::string getAlternativeSemantics(unsigned index) const
+ {
+ if (_alternativeList.size() <= index)
+ return std::string();
+ return _alternativeList[index]._semantics;
+ }
+ std::string getAlternativeSemantics(const std::string& enumerator) const
+ { return getAlternativeSemantics(getAlternativeIndex(enumerator)); }
+
+private:
+ SGSharedPtr<HLAEnumeratedDataType> _enumeratedDataType;
+
+ struct Alternative {
+ std::string _name;
+ SGSharedPtr<const HLADataType> _dataType;
+ std::string _semantics;
+ };
+
+ typedef std::vector<Alternative> AlternativeList;
+ AlternativeList _alternativeList;
+};
+
+} // namespace simgear
+
+#endif