From: Mathias Froehlich Date: Sat, 21 Jul 2012 10:55:53 +0000 (+0200) Subject: hla: Make HLAFixedRecordDataElement work with delayed data type setting. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=07d1358e0841162ba91e761d5b3d746f8a35510a;p=simgear.git hla: Make HLAFixedRecordDataElement work with delayed data type setting. --- diff --git a/simgear/hla/HLAFixedRecordDataElement.cxx b/simgear/hla/HLAFixedRecordDataElement.cxx index b9c0b855..00033982 100644 --- a/simgear/hla/HLAFixedRecordDataElement.cxx +++ b/simgear/hla/HLAFixedRecordDataElement.cxx @@ -96,24 +96,32 @@ HLAAbstractFixedRecordDataElement::setDataType(const HLAFixedRecordDataType* dat unsigned HLAAbstractFixedRecordDataElement::getNumFields() const { + if (!_dataType.valid()) + return 0; return _dataType->getNumFields(); } unsigned HLAAbstractFixedRecordDataElement::getFieldNumber(const std::string& name) const { + if (!_dataType.valid()) + return ~0u; return _dataType->getFieldNumber(name); } const HLADataType* HLAAbstractFixedRecordDataElement::getFieldDataType(unsigned i) const { + if (!_dataType.valid()) + return 0; return _dataType->getFieldDataType(i); } const HLADataType* HLAAbstractFixedRecordDataElement::getFieldDataType(const std::string& name) const { + if (!_dataType.valid()) + return 0; return getFieldDataType(getFieldNumber(name)); } @@ -129,6 +137,15 @@ HLAFixedRecordDataElement::~HLAFixedRecordDataElement() clearStamp(); } +bool +HLAFixedRecordDataElement::setDataType(const HLADataType* dataType) +{ + if (!HLAAbstractFixedRecordDataElement::setDataType(dataType)) + return false; + _fieldVector.resize(getNumFields()); + return true; +} + bool HLAFixedRecordDataElement::decodeField(HLADecodeStream& stream, unsigned i) { diff --git a/simgear/hla/HLAFixedRecordDataElement.hxx b/simgear/hla/HLAFixedRecordDataElement.hxx index 7a471e8d..ef1f2c44 100644 --- a/simgear/hla/HLAFixedRecordDataElement.hxx +++ b/simgear/hla/HLAFixedRecordDataElement.hxx @@ -58,6 +58,8 @@ public: HLAFixedRecordDataElement(const HLAFixedRecordDataType* dataType); virtual ~HLAFixedRecordDataElement(); + virtual bool setDataType(const HLADataType* dataType); + virtual bool decodeField(HLADecodeStream& stream, unsigned i); virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const;