]> git.mxchange.org Git - simgear.git/commitdiff
hla: Make HLAFixedRecordDataElement work with delayed data type setting.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Sat, 21 Jul 2012 10:55:53 +0000 (12:55 +0200)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Sat, 21 Jul 2012 10:55:53 +0000 (12:55 +0200)
simgear/hla/HLAFixedRecordDataElement.cxx
simgear/hla/HLAFixedRecordDataElement.hxx

index b9c0b8559cd15dc768b02a31e2290c244851b196..000339823eda0fa58a9b5c2edc0b6cef397fc6b1 100644 (file)
@@ -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)
 {
index 7a471e8dfcf8d2003bdaf51202553b71e64e6c47..ef1f2c440cffe3ca4cc814fa32aa2ee472fa19ff 100644 (file)
@@ -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;