Merge branch 'next' of git.gitorious.org:fg/simgear into next
This commit is contained in:
commit
a0c48de39d
@ -32,6 +32,7 @@ set(HLA_SOURCES
|
||||
HLABasicDataType.cxx
|
||||
HLADataElement.cxx
|
||||
HLADataType.cxx
|
||||
HLADataTypeVisitor.cxx
|
||||
HLAEnumeratedDataElement.cxx
|
||||
HLAEnumeratedDataType.cxx
|
||||
HLAFederate.cxx
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2009 - 2010 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||
// Copyright (C) 2009 - 2011 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,7 +22,9 @@
|
||||
namespace simgear {
|
||||
|
||||
HLAArrayDataType::HLAArrayDataType(const std::string& name) :
|
||||
HLADataType(name)
|
||||
HLADataType(name),
|
||||
_isOpaque(false),
|
||||
_isString(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -51,6 +53,18 @@ HLAArrayDataType::setElementDataType(const HLADataType* elementDataType)
|
||||
_elementDataType = elementDataType;
|
||||
}
|
||||
|
||||
void
|
||||
HLAArrayDataType::setIsOpaque(bool isOpaque)
|
||||
{
|
||||
_isOpaque = isOpaque;
|
||||
}
|
||||
|
||||
void
|
||||
HLAArrayDataType::setIsString(bool isString)
|
||||
{
|
||||
_isString = isString;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HLAFixedArrayDataType::HLAFixedArrayDataType(const std::string& name) :
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2009 - 2010 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||
// Copyright (C) 2009 - 2011 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
|
||||
@ -42,8 +42,18 @@ public:
|
||||
const HLADataType* getElementDataType() const
|
||||
{ return _elementDataType.get(); }
|
||||
|
||||
void setIsOpaque(bool isOpaque);
|
||||
bool getIsOpaque() const
|
||||
{ return _isOpaque; }
|
||||
|
||||
void setIsString(bool isString);
|
||||
bool getIsString() const
|
||||
{ return _isString; }
|
||||
|
||||
private:
|
||||
SGSharedPtr<const HLADataType> _elementDataType;
|
||||
bool _isOpaque;
|
||||
bool _isString;
|
||||
};
|
||||
|
||||
class HLAFixedArrayDataType : public HLAArrayDataType {
|
||||
|
188
simgear/hla/HLADataTypeVisitor.cxx
Normal file
188
simgear/hla/HLADataTypeVisitor.cxx
Normal file
@ -0,0 +1,188 @@
|
||||
// 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 "HLADataTypeVisitor.hxx"
|
||||
|
||||
#include "HLAArrayDataElement.hxx"
|
||||
#include "HLABasicDataElement.hxx"
|
||||
#include "HLADataTypeVisitor.hxx"
|
||||
#include "HLAEnumeratedDataElement.hxx"
|
||||
#include "HLAFixedRecordDataElement.hxx"
|
||||
#include "HLAVariantDataElement.hxx"
|
||||
|
||||
namespace simgear {
|
||||
|
||||
HLADataElementFactoryVisitor::~HLADataElementFactoryVisitor()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLADataType& dataType)
|
||||
{
|
||||
SG_LOG(SG_NETWORK, SG_ALERT, "HLA: Can not find a suitable data element for data type \""
|
||||
<< dataType.getName() << "\"");
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAInt8DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLASCharDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAUInt8DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLAUCharDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAInt16DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLAShortDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAUInt16DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLAUShortDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAInt32DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLAIntDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAUInt32DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLAUIntDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAInt64DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLALongDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAUInt64DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLAULongDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAFloat32DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLAFloatDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAFloat64DataType& dataType)
|
||||
{
|
||||
_dataElement = new HLADoubleDataElement(&dataType);
|
||||
}
|
||||
|
||||
class HLADataElementFactoryVisitor::ArrayDataElementFactory : public HLAArrayDataElement::DataElementFactory {
|
||||
public:
|
||||
virtual HLADataElement* createElement(const HLAArrayDataElement& element, unsigned index)
|
||||
{
|
||||
const HLADataType* dataType = element.getElementDataType();
|
||||
if (!dataType)
|
||||
return 0;
|
||||
|
||||
HLADataElementFactoryVisitor visitor;
|
||||
dataType->accept(visitor);
|
||||
return visitor.getDataElement();
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAFixedArrayDataType& dataType)
|
||||
{
|
||||
if (dataType.getIsString()) {
|
||||
_dataElement = new HLAStringDataElement(&dataType);
|
||||
} else {
|
||||
SGSharedPtr<HLAArrayDataElement> arrayDataElement;
|
||||
arrayDataElement = new HLAArrayDataElement(&dataType);
|
||||
arrayDataElement->setDataElementFactory(new ArrayDataElementFactory);
|
||||
arrayDataElement->setNumElements(dataType.getNumElements());
|
||||
_dataElement = arrayDataElement;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAVariableArrayDataType& dataType)
|
||||
{
|
||||
if (dataType.getIsString()) {
|
||||
_dataElement = new HLAStringDataElement(&dataType);
|
||||
} else {
|
||||
SGSharedPtr<HLAArrayDataElement> arrayDataElement;
|
||||
arrayDataElement = new HLAArrayDataElement(&dataType);
|
||||
arrayDataElement->setDataElementFactory(new ArrayDataElementFactory);
|
||||
_dataElement = arrayDataElement;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAEnumeratedDataType& dataType)
|
||||
{
|
||||
_dataElement = new HLAEnumeratedDataElement(&dataType);
|
||||
}
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAFixedRecordDataType& dataType)
|
||||
{
|
||||
SGSharedPtr<HLAFixedRecordDataElement> recordDataElement;
|
||||
recordDataElement = new HLAFixedRecordDataElement(&dataType);
|
||||
|
||||
unsigned numFields = dataType.getNumFields();
|
||||
for (unsigned i = 0; i < numFields; ++i) {
|
||||
HLADataElementFactoryVisitor visitor;
|
||||
dataType.getFieldDataType(i)->accept(visitor);
|
||||
recordDataElement->setField(i, visitor._dataElement.get());
|
||||
}
|
||||
|
||||
_dataElement = recordDataElement;
|
||||
}
|
||||
|
||||
class HLADataElementFactoryVisitor::VariantDataElementFactory : public HLAVariantDataElement::DataElementFactory {
|
||||
public:
|
||||
virtual HLADataElement* createElement(const HLAVariantDataElement& element, unsigned index)
|
||||
{
|
||||
const HLAVariantDataType* dataType = element.getDataType();
|
||||
if (!dataType)
|
||||
return 0;
|
||||
const HLADataType* alternativeDataType = element.getAlternativeDataType();
|
||||
if (!alternativeDataType)
|
||||
return 0;
|
||||
HLADataElementFactoryVisitor visitor;
|
||||
alternativeDataType->accept(visitor);
|
||||
return visitor.getDataElement();
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
HLADataElementFactoryVisitor::apply(const HLAVariantDataType& dataType)
|
||||
{
|
||||
SGSharedPtr<HLAVariantDataElement> variantDataElement;
|
||||
variantDataElement = new HLAVariantDataElement(&dataType);
|
||||
variantDataElement->setDataElementFactory(new VariantDataElementFactory);
|
||||
_dataElement = variantDataElement;
|
||||
}
|
||||
|
||||
} // namespace simgear
|
@ -24,7 +24,7 @@
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
#include "HLAArrayDataType.hxx"
|
||||
#include "HLABasicDataType.hxx"
|
||||
#include "HLADataTypeVisitor.hxx"
|
||||
#include "HLADataElement.hxx"
|
||||
#include "HLAEnumeratedDataType.hxx"
|
||||
#include "HLAFixedRecordDataType.hxx"
|
||||
#include "HLAVariantDataType.hxx"
|
||||
@ -629,6 +629,43 @@ inline void HLADataTypeEncodeVisitor::apply(const HLAVariableArrayDataType& data
|
||||
dataType.getSizeDataType()->accept(numElementsVisitor);
|
||||
}
|
||||
|
||||
/// Generate standard data elements according to the traversed type
|
||||
class HLADataElementFactoryVisitor : public HLADataTypeVisitor {
|
||||
public:
|
||||
virtual ~HLADataElementFactoryVisitor();
|
||||
|
||||
virtual void apply(const HLADataType& dataType);
|
||||
|
||||
virtual void apply(const HLAInt8DataType& dataType);
|
||||
virtual void apply(const HLAUInt8DataType& dataType);
|
||||
virtual void apply(const HLAInt16DataType& dataType);
|
||||
virtual void apply(const HLAUInt16DataType& dataType);
|
||||
virtual void apply(const HLAInt32DataType& dataType);
|
||||
virtual void apply(const HLAUInt32DataType& dataType);
|
||||
virtual void apply(const HLAInt64DataType& dataType);
|
||||
virtual void apply(const HLAUInt64DataType& dataType);
|
||||
virtual void apply(const HLAFloat32DataType& dataType);
|
||||
virtual void apply(const HLAFloat64DataType& dataType);
|
||||
|
||||
virtual void apply(const HLAFixedArrayDataType& dataType);
|
||||
virtual void apply(const HLAVariableArrayDataType& dataType);
|
||||
|
||||
virtual void apply(const HLAEnumeratedDataType& dataType);
|
||||
|
||||
virtual void apply(const HLAFixedRecordDataType& dataType);
|
||||
|
||||
virtual void apply(const HLAVariantDataType& dataType);
|
||||
|
||||
HLADataElement* getDataElement()
|
||||
{ return _dataElement.release(); }
|
||||
|
||||
protected:
|
||||
class ArrayDataElementFactory;
|
||||
class VariantDataElementFactory;
|
||||
|
||||
SGSharedPtr<HLADataElement> _dataElement;
|
||||
};
|
||||
|
||||
} // namespace simgear
|
||||
|
||||
#endif
|
||||
|
@ -186,9 +186,11 @@ public:
|
||||
bool readObjectModelTemplate(const std::string& objectModel,
|
||||
ObjectModelFactory& objectModelFactory);
|
||||
|
||||
/// Get the object class of a given name
|
||||
HLAObjectClass* getObjectClass(const std::string& name);
|
||||
const HLAObjectClass* getObjectClass(const std::string& name) const;
|
||||
|
||||
/// Get the interaction class of a given name
|
||||
HLAInteractionClass* getInteractionClass(const std::string& name);
|
||||
const HLAInteractionClass* getInteractionClass(const std::string& name) const;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2009 - 2010 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||
// Copyright (C) 2009 - 2011 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
|
||||
@ -439,6 +439,15 @@ HLAOMTXmlVisitor::getArrayDataType(const std::string& dataTypeName, HLAOMTXmlVis
|
||||
}
|
||||
arrayDataType->setElementDataType(elementDataType.get());
|
||||
|
||||
// Check if this should be a string data type
|
||||
if (elementDataType->toBasicDataType()) {
|
||||
if (dataTypeName == "HLAopaqueData") {
|
||||
arrayDataType->setIsOpaque(true);
|
||||
} else if (dataTypeName.find("String") != std::string::npos || dataTypeName.find("string") != std::string::npos) {
|
||||
arrayDataType->setIsString(true);
|
||||
}
|
||||
}
|
||||
|
||||
return arrayDataType;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ HLAObjectInstance::getAttributeDataElement(unsigned index) const
|
||||
return _rtiObjectInstance->getDataElement(index);
|
||||
}
|
||||
|
||||
class HLAObjectInstance::DataElementFactoryVisitor : public HLADataTypeVisitor {
|
||||
class HLAObjectInstance::DataElementFactoryVisitor : public HLADataElementFactoryVisitor {
|
||||
public:
|
||||
DataElementFactoryVisitor(const HLAPathElementMap& pathElementMap) :
|
||||
_pathElementMap(pathElementMap)
|
||||
@ -150,7 +150,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLASCharDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAUInt8DataType& dataType)
|
||||
{
|
||||
@ -158,7 +158,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLAUCharDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAInt16DataType& dataType)
|
||||
{
|
||||
@ -166,7 +166,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLAShortDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAUInt16DataType& dataType)
|
||||
{
|
||||
@ -174,7 +174,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLAUShortDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAInt32DataType& dataType)
|
||||
{
|
||||
@ -182,7 +182,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLAIntDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAUInt32DataType& dataType)
|
||||
{
|
||||
@ -190,7 +190,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLAUIntDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAInt64DataType& dataType)
|
||||
{
|
||||
@ -198,7 +198,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLALongDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAUInt64DataType& dataType)
|
||||
{
|
||||
@ -206,7 +206,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLAULongDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAFloat32DataType& dataType)
|
||||
{
|
||||
@ -214,7 +214,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLAFloatDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
virtual void apply(const HLAFloat64DataType& dataType)
|
||||
{
|
||||
@ -222,7 +222,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLADoubleDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
|
||||
class ArrayDataElementFactory : public HLAArrayDataElement::DataElementFactory {
|
||||
@ -287,7 +287,7 @@ public:
|
||||
if (_dataElement.valid())
|
||||
return;
|
||||
|
||||
_dataElement = new HLAEnumeratedDataElement(&dataType);
|
||||
HLADataElementFactoryVisitor::apply(dataType);
|
||||
}
|
||||
|
||||
virtual void apply(const HLAFixedRecordDataType& dataType)
|
||||
@ -357,9 +357,6 @@ public:
|
||||
_dataElement = variantDataElement;
|
||||
}
|
||||
|
||||
const SGSharedPtr<HLADataElement>& getDataElement() const
|
||||
{ return _dataElement; }
|
||||
|
||||
private:
|
||||
SGSharedPtr<HLADataElement> createDataElement(const HLADataElement::Path& path, const HLADataType& dataType)
|
||||
{
|
||||
@ -381,7 +378,6 @@ private:
|
||||
return dataElement;
|
||||
}
|
||||
|
||||
SGSharedPtr<HLADataElement> _dataElement;
|
||||
const HLAPathElementMap& _pathElementMap;
|
||||
HLADataElement::Path _path;
|
||||
};
|
||||
@ -413,26 +409,6 @@ HLAObjectInstance::setAttributes(const HLAAttributePathElementMap& attributePath
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HLAObjectInstance::requestAttributeUpdate(unsigned index)
|
||||
{
|
||||
if (!_rtiObjectInstance.valid()) {
|
||||
SG_LOG(SG_IO, SG_ALERT, "Trying to request attribute update for inactive object!");
|
||||
return;
|
||||
}
|
||||
_rtiObjectInstance->setRequestAttributeUpdate(index, true);
|
||||
}
|
||||
|
||||
void
|
||||
HLAObjectInstance::requestAttributeUpdate()
|
||||
{
|
||||
if (!_rtiObjectInstance.valid()) {
|
||||
SG_LOG(SG_IO, SG_ALERT, "Trying to request attribute update for inactive object!");
|
||||
return;
|
||||
}
|
||||
_rtiObjectInstance->setRequestAttributeUpdate(true);
|
||||
}
|
||||
|
||||
void
|
||||
HLAObjectInstance::registerInstance()
|
||||
{
|
||||
@ -471,16 +447,6 @@ HLAObjectInstance::deleteInstance(const RTIData& tag)
|
||||
_rtiObjectInstance->deleteObjectInstance(tag);
|
||||
}
|
||||
|
||||
void
|
||||
HLAObjectInstance::localDeleteInstance()
|
||||
{
|
||||
if (!_rtiObjectInstance.valid()) {
|
||||
SG_LOG(SG_IO, SG_ALERT, "Trying to delete inactive object!");
|
||||
return;
|
||||
}
|
||||
_rtiObjectInstance->localDeleteObjectInstance();
|
||||
}
|
||||
|
||||
void
|
||||
HLAObjectInstance::updateAttributeValues(const RTIData& tag)
|
||||
{
|
||||
@ -505,16 +471,6 @@ HLAObjectInstance::updateAttributeValues(const SGTimeStamp& timeStamp, const RTI
|
||||
_rtiObjectInstance->updateAttributeValues(timeStamp, tag);
|
||||
}
|
||||
|
||||
void
|
||||
HLAObjectInstance::reflectQueuedAttributeValues(const SGTimeStamp& timeStamp)
|
||||
{
|
||||
if (!_rtiObjectInstance.valid()) {
|
||||
SG_LOG(SG_IO, SG_INFO, "Not updating inactive object!");
|
||||
return;
|
||||
}
|
||||
_rtiObjectInstance->reflectQueuedAttributeValues(timeStamp);
|
||||
}
|
||||
|
||||
void
|
||||
HLAObjectInstance::removeInstance(const RTIData& tag)
|
||||
{
|
||||
|
@ -52,13 +52,8 @@ public:
|
||||
void setAttribute(unsigned index, const HLAPathElementMap& pathElementMap);
|
||||
void setAttributes(const HLAAttributePathElementMap& attributePathElementMap);
|
||||
|
||||
// Ask the rti to provide the attribute at index
|
||||
void requestAttributeUpdate(unsigned index);
|
||||
void requestAttributeUpdate();
|
||||
|
||||
void registerInstance();
|
||||
void deleteInstance(const RTIData& tag);
|
||||
void localDeleteInstance();
|
||||
|
||||
class AttributeCallback : public SGReferenced {
|
||||
public:
|
||||
@ -85,11 +80,6 @@ public:
|
||||
void updateAttributeValues(const RTIData& tag);
|
||||
void updateAttributeValues(const SGTimeStamp& timeStamp, const RTIData& tag);
|
||||
|
||||
// Retrieve queued up updates up to and including timestamp,
|
||||
// Note that this only applies to timestamped updates.
|
||||
// The unordered updates are reflected as they arrive
|
||||
void reflectQueuedAttributeValues(const SGTimeStamp& timeStamp);
|
||||
|
||||
private:
|
||||
void removeInstance(const RTIData& tag);
|
||||
void reflectAttributeValues(const RTIIndexDataPairList& dataPairList, const RTIData& tag);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2009 - 2010 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||
// Copyright (C) 2009 - 2011 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
|
||||
@ -17,16 +17,21 @@
|
||||
|
||||
#include "HLAPropertyDataElement.hxx"
|
||||
|
||||
#include "HLAArrayDataElement.hxx"
|
||||
#include "HLADataTypeVisitor.hxx"
|
||||
#include "HLAFixedRecordDataElement.hxx"
|
||||
#include "HLAVariantDataElement.hxx"
|
||||
|
||||
namespace simgear {
|
||||
|
||||
class HLAPropertyDataElement::DecodeVisitor : public HLADataTypeDecodeVisitor {
|
||||
class HLAPropertyDataElement::ScalarDecodeVisitor : public HLADataTypeDecodeVisitor {
|
||||
public:
|
||||
DecodeVisitor(HLADecodeStream& stream, SGPropertyNode& propertyNode) :
|
||||
ScalarDecodeVisitor(HLADecodeStream& stream, SGPropertyNode& propertyNode) :
|
||||
HLADataTypeDecodeVisitor(stream),
|
||||
_propertyNode(propertyNode)
|
||||
{ }
|
||||
virtual ~ScalarDecodeVisitor()
|
||||
{ }
|
||||
|
||||
virtual void apply(const HLAInt8DataType& dataType)
|
||||
{
|
||||
@ -89,43 +94,18 @@ public:
|
||||
_propertyNode.setDoubleValue(value);
|
||||
}
|
||||
|
||||
virtual void apply(const HLAFixedArrayDataType& dataType)
|
||||
{
|
||||
unsigned numElements = dataType.getNumElements();
|
||||
std::string value;
|
||||
value.reserve(numElements);
|
||||
for (unsigned i = 0; i < numElements; ++i) {
|
||||
HLATemplateDecodeVisitor<char> visitor(_stream);
|
||||
dataType.getElementDataType()->accept(visitor);
|
||||
value.push_back(visitor.getValue());
|
||||
}
|
||||
_propertyNode.setStringValue(value);
|
||||
}
|
||||
virtual void apply(const HLAVariableArrayDataType& dataType)
|
||||
{
|
||||
HLATemplateDecodeVisitor<unsigned> numElementsVisitor(_stream);
|
||||
dataType.getSizeDataType()->accept(numElementsVisitor);
|
||||
unsigned numElements = numElementsVisitor.getValue();
|
||||
std::string value;
|
||||
value.reserve(numElements);
|
||||
for (unsigned i = 0; i < numElements; ++i) {
|
||||
HLATemplateDecodeVisitor<char> visitor(_stream);
|
||||
dataType.getElementDataType()->accept(visitor);
|
||||
value.push_back(visitor.getValue());
|
||||
}
|
||||
_propertyNode.setStringValue(value);
|
||||
}
|
||||
|
||||
protected:
|
||||
SGPropertyNode& _propertyNode;
|
||||
};
|
||||
|
||||
class HLAPropertyDataElement::EncodeVisitor : public HLADataTypeEncodeVisitor {
|
||||
class HLAPropertyDataElement::ScalarEncodeVisitor : public HLADataTypeEncodeVisitor {
|
||||
public:
|
||||
EncodeVisitor(HLAEncodeStream& stream, const SGPropertyNode& propertyNode) :
|
||||
ScalarEncodeVisitor(HLAEncodeStream& stream, const SGPropertyNode& propertyNode) :
|
||||
HLADataTypeEncodeVisitor(stream),
|
||||
_propertyNode(propertyNode)
|
||||
{ }
|
||||
virtual ~ScalarEncodeVisitor()
|
||||
{ }
|
||||
|
||||
virtual void apply(const HLAInt8DataType& dataType)
|
||||
{
|
||||
@ -168,6 +148,116 @@ public:
|
||||
dataType.encode(_stream, _propertyNode.getDoubleValue());
|
||||
}
|
||||
|
||||
protected:
|
||||
const SGPropertyNode& _propertyNode;
|
||||
};
|
||||
|
||||
class HLAPropertyDataElement::ScalarDataElement : public HLADataElement {
|
||||
public:
|
||||
ScalarDataElement(const HLABasicDataType* dataType, SGPropertyNode* propertyNode);
|
||||
virtual ~ScalarDataElement();
|
||||
|
||||
virtual bool encode(HLAEncodeStream& stream) const;
|
||||
virtual bool decode(HLADecodeStream& stream);
|
||||
|
||||
virtual const HLADataType* getDataType() const;
|
||||
virtual bool setDataType(const HLADataType* dataType);
|
||||
|
||||
private:
|
||||
SGSharedPtr<const HLABasicDataType> _dataType;
|
||||
SGSharedPtr<SGPropertyNode> _propertyNode;
|
||||
};
|
||||
|
||||
HLAPropertyDataElement::ScalarDataElement::ScalarDataElement(const HLABasicDataType* dataType, SGPropertyNode* propertyNode) :
|
||||
_dataType(dataType),
|
||||
_propertyNode(propertyNode)
|
||||
{
|
||||
}
|
||||
|
||||
HLAPropertyDataElement::ScalarDataElement::~ScalarDataElement()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
HLAPropertyDataElement::ScalarDataElement::encode(HLAEncodeStream& stream) const
|
||||
{
|
||||
ScalarEncodeVisitor visitor(stream, *_propertyNode);
|
||||
_dataType->accept(visitor);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
HLAPropertyDataElement::ScalarDataElement::decode(HLADecodeStream& stream)
|
||||
{
|
||||
ScalarDecodeVisitor visitor(stream, *_propertyNode);
|
||||
_dataType->accept(visitor);
|
||||
return true;
|
||||
}
|
||||
|
||||
const HLADataType*
|
||||
HLAPropertyDataElement::ScalarDataElement::getDataType() const
|
||||
{
|
||||
return _dataType.get();
|
||||
}
|
||||
|
||||
bool
|
||||
HLAPropertyDataElement::ScalarDataElement::setDataType(const HLADataType* dataType)
|
||||
{
|
||||
if (!dataType)
|
||||
return false;
|
||||
const HLABasicDataType* basicDataType = dataType->toBasicDataType();
|
||||
if (!basicDataType)
|
||||
return false;
|
||||
_dataType = basicDataType;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class HLAPropertyDataElement::StringDecodeVisitor : public HLADataTypeDecodeVisitor {
|
||||
public:
|
||||
StringDecodeVisitor(HLADecodeStream& stream, SGPropertyNode& propertyNode) :
|
||||
HLADataTypeDecodeVisitor(stream),
|
||||
_propertyNode(propertyNode)
|
||||
{ }
|
||||
|
||||
virtual void apply(const HLAFixedArrayDataType& dataType)
|
||||
{
|
||||
unsigned numElements = dataType.getNumElements();
|
||||
std::string value;
|
||||
value.reserve(numElements);
|
||||
for (unsigned i = 0; i < numElements; ++i) {
|
||||
HLATemplateDecodeVisitor<char> visitor(_stream);
|
||||
dataType.getElementDataType()->accept(visitor);
|
||||
value.push_back(visitor.getValue());
|
||||
}
|
||||
_propertyNode.setStringValue(value);
|
||||
}
|
||||
virtual void apply(const HLAVariableArrayDataType& dataType)
|
||||
{
|
||||
HLATemplateDecodeVisitor<std::string::size_type> numElementsVisitor(_stream);
|
||||
dataType.getSizeDataType()->accept(numElementsVisitor);
|
||||
std::string::size_type numElements = numElementsVisitor.getValue();
|
||||
std::string value;
|
||||
value.reserve(numElements);
|
||||
for (std::string::size_type i = 0; i < numElements; ++i) {
|
||||
HLATemplateDecodeVisitor<char> visitor(_stream);
|
||||
dataType.getElementDataType()->accept(visitor);
|
||||
value.push_back(visitor.getValue());
|
||||
}
|
||||
_propertyNode.setStringValue(value);
|
||||
}
|
||||
|
||||
protected:
|
||||
SGPropertyNode& _propertyNode;
|
||||
};
|
||||
|
||||
class HLAPropertyDataElement::StringEncodeVisitor : public HLADataTypeEncodeVisitor {
|
||||
public:
|
||||
StringEncodeVisitor(HLAEncodeStream& stream, const SGPropertyNode& propertyNode) :
|
||||
HLADataTypeEncodeVisitor(stream),
|
||||
_propertyNode(propertyNode)
|
||||
{ }
|
||||
|
||||
virtual void apply(const HLAFixedArrayDataType& dataType)
|
||||
{
|
||||
unsigned numElements = dataType.getNumElements();
|
||||
@ -198,17 +288,228 @@ protected:
|
||||
const SGPropertyNode& _propertyNode;
|
||||
};
|
||||
|
||||
HLAPropertyDataElement::HLAPropertyDataElement(HLAPropertyReference* propertyReference) :
|
||||
_propertyReference(propertyReference)
|
||||
class HLAPropertyDataElement::StringDataElement : public HLADataElement {
|
||||
public:
|
||||
StringDataElement(const HLAArrayDataType* dataType, SGPropertyNode* propertyNode);
|
||||
virtual ~StringDataElement();
|
||||
|
||||
virtual bool encode(HLAEncodeStream& stream) const;
|
||||
virtual bool decode(HLADecodeStream& stream);
|
||||
|
||||
virtual const HLADataType* getDataType() const;
|
||||
virtual bool setDataType(const HLADataType* dataType);
|
||||
|
||||
private:
|
||||
SGSharedPtr<const HLAArrayDataType> _dataType;
|
||||
SGSharedPtr<SGPropertyNode> _propertyNode;
|
||||
};
|
||||
|
||||
HLAPropertyDataElement::StringDataElement::StringDataElement(const HLAArrayDataType* dataType, SGPropertyNode* propertyNode) :
|
||||
_dataType(dataType),
|
||||
_propertyNode(propertyNode)
|
||||
{
|
||||
}
|
||||
|
||||
HLAPropertyDataElement::HLAPropertyDataElement(const HLADataType* dataType, HLAPropertyReference* propertyReference) :
|
||||
_dataType(dataType),
|
||||
_propertyReference(propertyReference)
|
||||
HLAPropertyDataElement::StringDataElement::~StringDataElement()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
HLAPropertyDataElement::StringDataElement::encode(HLAEncodeStream& stream) const
|
||||
{
|
||||
StringEncodeVisitor visitor(stream, *_propertyNode);
|
||||
_dataType->accept(visitor);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
HLAPropertyDataElement::StringDataElement::decode(HLADecodeStream& stream)
|
||||
{
|
||||
StringDecodeVisitor visitor(stream, *_propertyNode);
|
||||
_dataType->accept(visitor);
|
||||
return true;
|
||||
}
|
||||
|
||||
const HLADataType*
|
||||
HLAPropertyDataElement::StringDataElement::getDataType() const
|
||||
{
|
||||
return _dataType.get();
|
||||
}
|
||||
|
||||
bool
|
||||
HLAPropertyDataElement::StringDataElement::setDataType(const HLADataType* dataType)
|
||||
{
|
||||
if (!dataType)
|
||||
return false;
|
||||
const HLAArrayDataType* arrayDataType = dataType->toArrayDataType();
|
||||
if (!arrayDataType)
|
||||
return false;
|
||||
const HLADataType* elementDataType = arrayDataType->getElementDataType();
|
||||
if (!elementDataType)
|
||||
return false;
|
||||
if (!elementDataType->toBasicDataType())
|
||||
return false;
|
||||
_dataType = arrayDataType;
|
||||
return true;
|
||||
}
|
||||
|
||||
class HLAPropertyDataElement::DataElementFactoryVisitor : public HLADataTypeVisitor {
|
||||
public:
|
||||
DataElementFactoryVisitor(SGPropertyNode* propertyNode) :
|
||||
_propertyNode(propertyNode)
|
||||
{ }
|
||||
virtual ~DataElementFactoryVisitor()
|
||||
{ }
|
||||
|
||||
virtual void apply(const HLADataType& dataType)
|
||||
{
|
||||
SG_LOG(SG_NETWORK, SG_ALERT, "HLA: Can not find a suitable data element for data type \""
|
||||
<< dataType.getName() << "\"");
|
||||
}
|
||||
|
||||
virtual void apply(const HLAInt8DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAUInt8DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAInt16DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAUInt16DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAInt32DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAUInt32DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAInt64DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAUInt64DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAFloat32DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
virtual void apply(const HLAFloat64DataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(&dataType, _propertyNode.get());
|
||||
}
|
||||
|
||||
class ArrayDataElementFactory : public HLAArrayDataElement::DataElementFactory {
|
||||
public:
|
||||
ArrayDataElementFactory(SGPropertyNode* propertyNode) :
|
||||
_propertyNode(propertyNode)
|
||||
{ }
|
||||
virtual HLADataElement* createElement(const HLAArrayDataElement& element, unsigned index)
|
||||
{
|
||||
const HLADataType* dataType = element.getElementDataType();
|
||||
if (!dataType)
|
||||
return 0;
|
||||
|
||||
SGPropertyNode* parent = _propertyNode->getParent();
|
||||
DataElementFactoryVisitor visitor(parent->getChild(_propertyNode->getNameString(), index, true));
|
||||
dataType->accept(visitor);
|
||||
return visitor.getDataElement();
|
||||
}
|
||||
private:
|
||||
SGSharedPtr<SGPropertyNode> _propertyNode;
|
||||
};
|
||||
|
||||
virtual void apply(const HLAFixedArrayDataType& dataType)
|
||||
{
|
||||
if (dataType.getIsString()) {
|
||||
_dataElement = new StringDataElement(&dataType, _propertyNode.get());
|
||||
} else {
|
||||
SGSharedPtr<HLAArrayDataElement> arrayDataElement;
|
||||
arrayDataElement = new HLAArrayDataElement(&dataType);
|
||||
arrayDataElement->setDataElementFactory(new ArrayDataElementFactory(_propertyNode.get()));
|
||||
arrayDataElement->setNumElements(dataType.getNumElements());
|
||||
_dataElement = arrayDataElement;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void apply(const HLAVariableArrayDataType& dataType)
|
||||
{
|
||||
if (dataType.getIsString()) {
|
||||
_dataElement = new StringDataElement(&dataType, _propertyNode.get());
|
||||
} else {
|
||||
SGSharedPtr<HLAArrayDataElement> arrayDataElement;
|
||||
arrayDataElement = new HLAArrayDataElement(&dataType);
|
||||
arrayDataElement->setDataElementFactory(new ArrayDataElementFactory(_propertyNode.get()));
|
||||
_dataElement = arrayDataElement;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void apply(const HLAEnumeratedDataType& dataType)
|
||||
{
|
||||
_dataElement = new ScalarDataElement(dataType.getRepresentation(), _propertyNode.get());
|
||||
}
|
||||
|
||||
virtual void apply(const HLAFixedRecordDataType& dataType)
|
||||
{
|
||||
SGSharedPtr<HLAFixedRecordDataElement> recordDataElement;
|
||||
recordDataElement = new HLAFixedRecordDataElement(&dataType);
|
||||
|
||||
unsigned numFields = dataType.getNumFields();
|
||||
for (unsigned i = 0; i < numFields; ++i) {
|
||||
DataElementFactoryVisitor visitor(_propertyNode->getChild(dataType.getFieldName(i), 0, true));
|
||||
dataType.getFieldDataType(i)->accept(visitor);
|
||||
recordDataElement->setField(i, visitor._dataElement.get());
|
||||
}
|
||||
|
||||
_dataElement = recordDataElement;
|
||||
}
|
||||
|
||||
class VariantDataElementFactory : public HLAVariantDataElement::DataElementFactory {
|
||||
public:
|
||||
VariantDataElementFactory(SGPropertyNode* propertyNode) :
|
||||
_propertyNode(propertyNode)
|
||||
{ }
|
||||
virtual HLADataElement* createElement(const HLAVariantDataElement& element, unsigned index)
|
||||
{
|
||||
const HLAVariantDataType* dataType = element.getDataType();
|
||||
if (!dataType)
|
||||
return 0;
|
||||
const HLADataType* alternativeDataType = element.getAlternativeDataType();
|
||||
if (!alternativeDataType)
|
||||
return 0;
|
||||
DataElementFactoryVisitor visitor(_propertyNode->getChild(dataType->getAlternativeName(index), 0, true));
|
||||
alternativeDataType->accept(visitor);
|
||||
return visitor.getDataElement();
|
||||
}
|
||||
private:
|
||||
SGSharedPtr<SGPropertyNode> _propertyNode;
|
||||
};
|
||||
|
||||
virtual void apply(const HLAVariantDataType& dataType)
|
||||
{
|
||||
SGSharedPtr<HLAVariantDataElement> variantDataElement;
|
||||
variantDataElement = new HLAVariantDataElement(&dataType);
|
||||
variantDataElement->setDataElementFactory(new VariantDataElementFactory(_propertyNode.get()));
|
||||
_dataElement = variantDataElement;
|
||||
}
|
||||
|
||||
HLADataElement* getDataElement()
|
||||
{ return _dataElement.release(); }
|
||||
|
||||
private:
|
||||
SGSharedPtr<SGPropertyNode> _propertyNode;
|
||||
SGSharedPtr<HLADataElement> _dataElement;
|
||||
};
|
||||
|
||||
HLAPropertyDataElement::HLAPropertyDataElement()
|
||||
{
|
||||
}
|
||||
@ -224,6 +525,11 @@ HLAPropertyDataElement::HLAPropertyDataElement(const HLADataType* dataType, SGPr
|
||||
setPropertyNode(propertyNode);
|
||||
}
|
||||
|
||||
HLAPropertyDataElement::HLAPropertyDataElement(const HLADataType* dataType) :
|
||||
_dataType(dataType)
|
||||
{
|
||||
}
|
||||
|
||||
HLAPropertyDataElement::~HLAPropertyDataElement()
|
||||
{
|
||||
}
|
||||
@ -231,32 +537,38 @@ HLAPropertyDataElement::~HLAPropertyDataElement()
|
||||
bool
|
||||
HLAPropertyDataElement::encode(HLAEncodeStream& stream) const
|
||||
{
|
||||
if (_dataElement.valid()) {
|
||||
return _dataElement->encode(stream);
|
||||
} else {
|
||||
if (!_dataType.valid())
|
||||
return false;
|
||||
if (const SGPropertyNode* propertyNode = getPropertyNode()) {
|
||||
EncodeVisitor visitor(stream, *propertyNode);
|
||||
_dataType->accept(visitor);
|
||||
} else {
|
||||
HLADataTypeEncodeVisitor visitor(stream);
|
||||
_dataType->accept(visitor);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
HLAPropertyDataElement::decode(HLADecodeStream& stream)
|
||||
{
|
||||
if (!_dataType.valid())
|
||||
if (_dataElement.valid()) {
|
||||
return _dataElement->decode(stream);
|
||||
} else if (!_dataType.valid()) {
|
||||
// We cant do anything if the data type is not valid
|
||||
return false;
|
||||
if (SGPropertyNode* propertyNode = getPropertyNode()) {
|
||||
DecodeVisitor visitor(stream, *propertyNode);
|
||||
} else {
|
||||
HLADataElementFactoryVisitor visitor;
|
||||
_dataType->accept(visitor);
|
||||
_dataElement = visitor.getDataElement();
|
||||
if (_dataElement.valid()) {
|
||||
return _dataElement->decode(stream);
|
||||
} else {
|
||||
HLADataTypeDecodeVisitor visitor(stream);
|
||||
_dataType->accept(visitor);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const HLADataType*
|
||||
HLAPropertyDataElement::getDataType() const
|
||||
@ -267,41 +579,52 @@ HLAPropertyDataElement::getDataType() const
|
||||
bool
|
||||
HLAPropertyDataElement::setDataType(const HLADataType* dataType)
|
||||
{
|
||||
if (dataType->toBasicDataType()) {
|
||||
_dataType = dataType;
|
||||
if (_dataType.valid() && _propertyNode.valid())
|
||||
_dataElement = createDataElement(_dataType, _propertyNode);
|
||||
return true;
|
||||
} else {
|
||||
const HLAArrayDataType* arrayDataType = dataType->toArrayDataType();
|
||||
if (arrayDataType && arrayDataType->getElementDataType() &&
|
||||
arrayDataType->getElementDataType()->toBasicDataType()) {
|
||||
_dataType = dataType;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
HLAPropertyDataElement::setPropertyNode(SGPropertyNode* propertyNode)
|
||||
{
|
||||
_propertyReference = new HLAPropertyReference;
|
||||
_propertyReference->setRootNode(propertyNode);
|
||||
_propertyNode = propertyNode;
|
||||
if (_dataType.valid() && _propertyNode.valid())
|
||||
_dataElement = createDataElement(_dataType, _propertyNode);
|
||||
}
|
||||
|
||||
SGPropertyNode*
|
||||
HLAPropertyDataElement::getPropertyNode()
|
||||
{
|
||||
if (!_propertyReference.valid())
|
||||
return 0;
|
||||
return _propertyReference->getPropertyNode();
|
||||
return _propertyNode.get();
|
||||
}
|
||||
|
||||
const SGPropertyNode*
|
||||
HLAPropertyDataElement::getPropertyNode() const
|
||||
{
|
||||
if (!_propertyReference.valid())
|
||||
return 0;
|
||||
return _propertyReference->getPropertyNode();
|
||||
return _propertyNode.get();
|
||||
}
|
||||
|
||||
HLADataElement*
|
||||
HLAPropertyDataElement::createDataElement(const SGSharedPtr<const HLADataType>& dataType,
|
||||
const SGSharedPtr<SGPropertyNode>& propertyNode)
|
||||
{
|
||||
DataElementFactoryVisitor visitor(propertyNode);
|
||||
dataType->accept(visitor);
|
||||
SGSharedPtr<HLADataElement> dataElement = visitor.getDataElement();
|
||||
|
||||
// Copy over the content of the previous data element if there is any.
|
||||
if (_dataElement.valid()) {
|
||||
// FIXME is encode/decode the right tool here??
|
||||
RTIData data;
|
||||
HLAEncodeStream encodeStream(data);
|
||||
if (_dataElement->encode(encodeStream)) {
|
||||
HLADecodeStream decodeStream(data);
|
||||
dataElement->decode(decodeStream);
|
||||
}
|
||||
}
|
||||
|
||||
return dataElement.release();
|
||||
}
|
||||
|
||||
} // namespace simgear
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2009 - 2010 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||
// Copyright (C) 2009 - 2011 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
|
||||
@ -18,77 +18,17 @@
|
||||
#ifndef HLAPropertyDataElement_hxx
|
||||
#define HLAPropertyDataElement_hxx
|
||||
|
||||
#include <set>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include "HLADataElement.hxx"
|
||||
|
||||
namespace simgear {
|
||||
|
||||
class HLAPropertyReference : public SGReferenced {
|
||||
public:
|
||||
HLAPropertyReference()
|
||||
{ }
|
||||
HLAPropertyReference(const std::string& relativePath) :
|
||||
_relativePath(relativePath)
|
||||
{ }
|
||||
|
||||
SGPropertyNode* getPropertyNode()
|
||||
{ return _propertyNode.get(); }
|
||||
|
||||
void setRootNode(SGPropertyNode* rootNode)
|
||||
{
|
||||
if (!rootNode)
|
||||
_propertyNode.clear();
|
||||
else
|
||||
_propertyNode = rootNode->getNode(_relativePath, true);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _relativePath;
|
||||
SGSharedPtr<SGPropertyNode> _propertyNode;
|
||||
};
|
||||
|
||||
class HLAPropertyReferenceSet : public SGReferenced {
|
||||
public:
|
||||
void insert(const SGSharedPtr<HLAPropertyReference>& propertyReference)
|
||||
{
|
||||
_propertyReferenceSet.insert(propertyReference);
|
||||
propertyReference->setRootNode(_rootNode.get());
|
||||
}
|
||||
void remove(const SGSharedPtr<HLAPropertyReference>& propertyReference)
|
||||
{
|
||||
PropertyReferenceSet::iterator i = _propertyReferenceSet.find(propertyReference);
|
||||
if (i == _propertyReferenceSet.end())
|
||||
return;
|
||||
_propertyReferenceSet.erase(i);
|
||||
propertyReference->setRootNode(0);
|
||||
}
|
||||
|
||||
void setRootNode(SGPropertyNode* rootNode)
|
||||
{
|
||||
_rootNode = rootNode;
|
||||
for (PropertyReferenceSet::iterator i = _propertyReferenceSet.begin();
|
||||
i != _propertyReferenceSet.end(); ++i) {
|
||||
(*i)->setRootNode(_rootNode.get());
|
||||
}
|
||||
}
|
||||
SGPropertyNode* getRootNode()
|
||||
{ return _rootNode.get(); }
|
||||
|
||||
private:
|
||||
SGSharedPtr<SGPropertyNode> _rootNode;
|
||||
|
||||
typedef std::set<SGSharedPtr<HLAPropertyReference> > PropertyReferenceSet;
|
||||
PropertyReferenceSet _propertyReferenceSet;
|
||||
};
|
||||
|
||||
class HLAPropertyDataElement : public HLADataElement {
|
||||
public:
|
||||
HLAPropertyDataElement(HLAPropertyReference* propertyReference);
|
||||
HLAPropertyDataElement(const HLADataType* dataType, HLAPropertyReference* propertyReference);
|
||||
HLAPropertyDataElement();
|
||||
HLAPropertyDataElement(SGPropertyNode* propertyNode);
|
||||
HLAPropertyDataElement(const HLADataType* dataType, SGPropertyNode* propertyNode);
|
||||
HLAPropertyDataElement(const HLADataType* dataType);
|
||||
virtual ~HLAPropertyDataElement();
|
||||
|
||||
virtual bool encode(HLAEncodeStream& stream) const;
|
||||
@ -102,11 +42,20 @@ public:
|
||||
const SGPropertyNode* getPropertyNode() const;
|
||||
|
||||
private:
|
||||
class DecodeVisitor;
|
||||
class EncodeVisitor;
|
||||
HLADataElement*
|
||||
createDataElement(const SGSharedPtr<const HLADataType>& dataType, const SGSharedPtr<SGPropertyNode>& propertyNode);
|
||||
|
||||
class ScalarDecodeVisitor;
|
||||
class ScalarEncodeVisitor;
|
||||
class ScalarDataElement;
|
||||
class StringDecodeVisitor;
|
||||
class StringEncodeVisitor;
|
||||
class StringDataElement;
|
||||
class DataElementFactoryVisitor;
|
||||
|
||||
SGSharedPtr<const HLADataType> _dataType;
|
||||
SGSharedPtr<HLAPropertyReference> _propertyReference;
|
||||
SGSharedPtr<HLADataElement> _dataElement;
|
||||
SGSharedPtr<SGPropertyNode> _propertyNode;
|
||||
};
|
||||
|
||||
} // namespace simgear
|
||||
|
@ -35,6 +35,7 @@ libsghla_a_SOURCES = \
|
||||
HLABasicDataType.cxx \
|
||||
HLADataElement.cxx \
|
||||
HLADataType.cxx \
|
||||
HLADataTypeVisitor.cxx \
|
||||
HLAEnumeratedDataElement.cxx \
|
||||
HLAEnumeratedDataType.cxx \
|
||||
HLAFederate.cxx \
|
||||
|
@ -299,6 +299,8 @@ public:
|
||||
{ _rtiAmbassador.timeAdvanceRequest(toFedTime(time)); }
|
||||
void timeAdvanceRequestAvailable(const SGTimeStamp& time)
|
||||
{ _rtiAmbassador.timeAdvanceRequestAvailable(toFedTime(time)); }
|
||||
void flushQueueRequest(const SGTimeStamp& time)
|
||||
{ _rtiAmbassador.flushQueueRequest(toFedTime(time)); }
|
||||
|
||||
bool queryGALT(SGTimeStamp& timeStamp)
|
||||
{
|
||||
|
@ -788,28 +788,28 @@ RTI13Federate::enableTimeConstrained()
|
||||
try {
|
||||
_ambassador->enableTimeConstrained();
|
||||
} catch (RTI::TimeConstrainedAlreadyEnabled& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::EnableTimeConstrainedPending& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::TimeAdvanceAlreadyInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::ConcurrentAccessAttempted& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederateNotExecutionMember& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::SaveInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RestoreInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RTIinternalError& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -833,22 +833,22 @@ RTI13Federate::disableTimeConstrained()
|
||||
_ambassador->disableTimeConstrained();
|
||||
_federateAmbassador->_timeConstrainedEnabled = false;
|
||||
} catch (RTI::TimeConstrainedWasNotEnabled& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederateNotExecutionMember& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::ConcurrentAccessAttempted& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::SaveInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RestoreInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RTIinternalError& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time constrained: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -877,34 +877,34 @@ RTI13Federate::enableTimeRegulation(const SGTimeStamp& lookahead)
|
||||
try {
|
||||
_ambassador->enableTimeRegulation(lookahead);
|
||||
} catch (RTI::TimeRegulationAlreadyEnabled& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::EnableTimeRegulationPending& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::TimeAdvanceAlreadyInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::InvalidFederationTime& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::InvalidLookahead& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::ConcurrentAccessAttempted& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederateNotExecutionMember& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::SaveInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RestoreInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RTIinternalError& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -928,22 +928,22 @@ RTI13Federate::disableTimeRegulation()
|
||||
_ambassador->disableTimeRegulation();
|
||||
_federateAmbassador->_timeRegulationEnabled = false;
|
||||
} catch (RTI::TimeRegulationWasNotEnabled& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::ConcurrentAccessAttempted& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederateNotExecutionMember& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::SaveInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RestoreInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RTIinternalError& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -991,7 +991,7 @@ bool
|
||||
RTI13Federate::timeAdvanceRequest(const SGTimeStamp& timeStamp)
|
||||
{
|
||||
if (!_ambassador.valid()) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation at unconnected federate.");
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time at unconnected federate.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -999,34 +999,34 @@ RTI13Federate::timeAdvanceRequest(const SGTimeStamp& timeStamp)
|
||||
_ambassador->timeAdvanceRequest(timeStamp);
|
||||
_federateAmbassador->_timeAdvancePending = true;
|
||||
} catch (RTI::InvalidFederationTime& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederationTimeAlreadyPassed& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::TimeAdvanceAlreadyInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::EnableTimeRegulationPending& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::EnableTimeConstrainedPending& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederateNotExecutionMember& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::ConcurrentAccessAttempted& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::SaveInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RestoreInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RTIinternalError& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1037,7 +1037,7 @@ bool
|
||||
RTI13Federate::timeAdvanceRequestAvailable(const SGTimeStamp& timeStamp)
|
||||
{
|
||||
if (!_ambassador.valid()) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation at unconnected federate.");
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time at unconnected federate.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1045,34 +1045,80 @@ RTI13Federate::timeAdvanceRequestAvailable(const SGTimeStamp& timeStamp)
|
||||
_ambassador->timeAdvanceRequestAvailable(timeStamp);
|
||||
_federateAmbassador->_timeAdvancePending = true;
|
||||
} catch (RTI::InvalidFederationTime& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederationTimeAlreadyPassed& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::TimeAdvanceAlreadyInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::EnableTimeRegulationPending& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::EnableTimeConstrainedPending& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederateNotExecutionMember& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::ConcurrentAccessAttempted& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::SaveInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RestoreInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RTIinternalError& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not advance time: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
RTI13Federate::flushQueueRequest(const SGTimeStamp& timeStamp)
|
||||
{
|
||||
if (!_ambassador.valid()) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue at unconnected federate.");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
_ambassador->flushQueueRequest(timeStamp);
|
||||
_federateAmbassador->_timeAdvancePending = true;
|
||||
} catch (RTI::InvalidFederationTime& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederationTimeAlreadyPassed& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::TimeAdvanceAlreadyInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::EnableTimeRegulationPending& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::EnableTimeConstrainedPending& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::FederateNotExecutionMember& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::ConcurrentAccessAttempted& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::SaveInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RestoreInProgress& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
} catch (RTI::RTIinternalError& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not flush queue: " << e._name << " " << e._reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1261,21 +1307,21 @@ RTI13Federate::getObjectInstance(const std::string& objectInstanceName)
|
||||
objectHandle = _ambassador->getObjectInstanceHandle(objectInstanceName);
|
||||
FederateAmbassador::ObjectInstanceMap::iterator i = _federateAmbassador->_objectInstanceMap.find(objectHandle);
|
||||
if (i == _federateAmbassador->_objectInstanceMap.end()) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: ObjectInstance not found.");
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object instance: ObjectInstance not found.");
|
||||
return 0;
|
||||
}
|
||||
return i->second;
|
||||
} catch (RTI::ObjectNotKnown& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object instance: " << e._name << " " << e._reason);
|
||||
return 0;
|
||||
} catch (RTI::FederateNotExecutionMember& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object instance: " << e._name << " " << e._reason);
|
||||
return 0;
|
||||
} catch (RTI::ConcurrentAccessAttempted& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object instance: " << e._name << " " << e._reason);
|
||||
return 0;
|
||||
} catch (RTI::RTIinternalError& e) {
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
|
||||
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object instance: " << e._name << " " << e._reason);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
|
||||
virtual bool timeAdvanceRequest(const SGTimeStamp& timeStamp);
|
||||
virtual bool timeAdvanceRequestAvailable(const SGTimeStamp& timeStamp);
|
||||
virtual bool flushQueueRequest(const SGTimeStamp& timeStamp);
|
||||
virtual bool getTimeAdvancePending();
|
||||
|
||||
virtual bool queryFederateTime(SGTimeStamp& timeStamp);
|
||||
|
@ -66,6 +66,7 @@ public:
|
||||
|
||||
virtual bool timeAdvanceRequest(const SGTimeStamp& fedTime) = 0;
|
||||
virtual bool timeAdvanceRequestAvailable(const SGTimeStamp& timeStamp) = 0;
|
||||
virtual bool flushQueueRequest(const SGTimeStamp& timeStamp) = 0;
|
||||
virtual bool getTimeAdvancePending() = 0;
|
||||
|
||||
virtual bool queryFederateTime(SGTimeStamp& timeStamp) = 0;
|
||||
|
@ -133,6 +133,8 @@ public:
|
||||
} else {
|
||||
_attributeData[i].setUpdateEnabled(false);
|
||||
_attributeData[i].setOwned(false);
|
||||
if (getAttributeSubscribed(i))
|
||||
_attributeData[i].setRequestUpdate(true);
|
||||
}
|
||||
}
|
||||
_attributeData.resize(numAttributes);
|
||||
@ -140,9 +142,13 @@ public:
|
||||
if (getAttributePublished(i)) {
|
||||
_attributeData[i].setUpdateEnabled(true);
|
||||
_attributeData[i].setOwned(owned);
|
||||
if (!owned && getAttributeSubscribed(i))
|
||||
_attributeData[i].setRequestUpdate(true);
|
||||
} else {
|
||||
_attributeData[i].setUpdateEnabled(false);
|
||||
_attributeData[i].setOwned(false);
|
||||
if (getAttributeSubscribed(i))
|
||||
_attributeData[i].setRequestUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,3 +57,12 @@ target_link_libraries(httpget
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${WINSOCK_LIBRARY}
|
||||
${RT_LIBRARY})
|
||||
|
||||
add_executable(decode_binobj decode_binobj.cxx)
|
||||
target_link_libraries(decode_binobj
|
||||
sgio sgbucket sgstructure sgthreads sgtiming sgmisc sgdebug
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${WINSOCK_LIBRARY}
|
||||
${ZLIB_LIBRARY}
|
||||
${RT_LIBRARY})
|
||||
|
@ -4,7 +4,10 @@
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,29 +27,24 @@
|
||||
#ifndef _SG_BINOBJ_HXX
|
||||
#define _SG_BINOBJ_HXX
|
||||
|
||||
#include <zlib.h> // for gzFile
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/math/sg_types.hxx>
|
||||
#include <simgear/bucket/newbucket.hxx>
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
/** STL Structure used to store object information */
|
||||
typedef std::vector < int_list > group_list;
|
||||
typedef group_list::iterator group_list_iterator;
|
||||
typedef group_list::const_iterator const_group_list_iterator;
|
||||
|
||||
|
||||
/** Magic Number for our file format */
|
||||
#define SG_FILE_MAGIC_NUMBER ( ('S'<<24) + ('G'<<16) + SG_BINOBJ_VERSION )
|
||||
|
||||
// forward decls
|
||||
class SGBucket;
|
||||
class SGPath;
|
||||
|
||||
/**
|
||||
* A class to manipulate the simgear 3d object format.
|
||||
@ -85,6 +80,7 @@ typedef group_list::const_iterator const_group_list_iterator;
|
||||
* - vertex: FLOAT, FLOAT, FLOAT
|
||||
*/
|
||||
class SGBinObject {
|
||||
private:
|
||||
unsigned short version;
|
||||
|
||||
SGVec3d gbs_center;
|
||||
@ -119,6 +115,24 @@ class SGBinObject {
|
||||
group_list fans_tc; // fans texture coordinate index
|
||||
string_list fan_materials; // fans materials
|
||||
|
||||
void read_properties(gzFile fp, int nproperties);
|
||||
|
||||
void read_object( gzFile fp,
|
||||
int obj_type,
|
||||
int nproperties,
|
||||
int nelements,
|
||||
group_list& vertices,
|
||||
group_list& normals,
|
||||
group_list& colors,
|
||||
group_list& texCoords,
|
||||
string_list& materials);
|
||||
|
||||
void write_header(gzFile fp, int type, int nProps, int nElements);
|
||||
void write_objects(gzFile fp, int type, const group_list& verts,
|
||||
const group_list& normals, const group_list& colors,
|
||||
const group_list& texCoords, const string_list& materials);
|
||||
|
||||
unsigned int count_objects(const string_list& materials);
|
||||
public:
|
||||
|
||||
inline unsigned short get_version() const { return version; }
|
||||
@ -207,6 +221,9 @@ public:
|
||||
*/
|
||||
bool write_bin( const std::string& base, const std::string& name, const SGBucket& b );
|
||||
|
||||
|
||||
bool write_bin_file(const SGPath& file);
|
||||
|
||||
/**
|
||||
* Write out the structures to an ASCII file. We assume that the
|
||||
* groups come to us sorted by material property. If not, things
|
||||
|
@ -1938,6 +1938,36 @@ struct Hash
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/** Convenience class for change listener callbacks without
|
||||
* creating a derived class implementing a "valueChanged" method.
|
||||
* Also removes listener on destruction automatically.
|
||||
*/
|
||||
template<class T>
|
||||
class SGPropertyChangeCallback
|
||||
: public SGPropertyChangeListener
|
||||
{
|
||||
public:
|
||||
SGPropertyChangeCallback(T* obj, void (T::*method)(SGPropertyNode*),
|
||||
SGPropertyNode_ptr property,bool initial=false)
|
||||
: _obj(obj), _callback(method), _property(property)
|
||||
{
|
||||
_property->addChangeListener(this,initial);
|
||||
}
|
||||
virtual ~SGPropertyChangeCallback()
|
||||
{
|
||||
_property->removeChangeListener(this);
|
||||
}
|
||||
void valueChanged (SGPropertyNode * node)
|
||||
{
|
||||
(_obj->*_callback)(node);
|
||||
}
|
||||
private:
|
||||
T* _obj;
|
||||
void (T::*_callback)(SGPropertyNode*);
|
||||
SGPropertyNode_ptr _property;
|
||||
};
|
||||
|
||||
#endif // __PROPS_HXX
|
||||
|
||||
// end of props.hxx
|
||||
|
Loading…
Reference in New Issue
Block a user