-// 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
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
+#ifdef HAVE_CONFIG_H
+# include <simgear_config.h>
+#endif
+
+#include <simgear/compiler.h>
+
#include "HLAFixedRecordDataElement.hxx"
#include <string>
#include <vector>
#include <simgear/debug/logstream.hxx>
+
+#include "HLADataElementVisitor.hxx"
#include "HLADataTypeVisitor.hxx"
namespace simgear {
{
}
+void
+HLAAbstractFixedRecordDataElement::accept(HLADataElementVisitor& visitor)
+{
+ visitor.apply(*this);
+}
+
+void
+HLAAbstractFixedRecordDataElement::accept(HLAConstDataElementVisitor& visitor) const
+{
+ visitor.apply(*this);
+}
+
bool
HLAAbstractFixedRecordDataElement::decode(HLADecodeStream& stream)
{
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));
}
HLAFixedRecordDataElement::~HLAFixedRecordDataElement()
{
+ clearStamp();
+}
+
+bool
+HLAFixedRecordDataElement::setDataType(const HLADataType* dataType)
+{
+ if (!HLAAbstractFixedRecordDataElement::setDataType(dataType))
+ return false;
+ _fieldVector.resize(getNumFields());
+ return true;
}
bool
{
if (getNumFields() <= index)
return;
+ if (_fieldVector[index].valid())
+ _fieldVector[index]->clearStamp();
_fieldVector[index] = value;
+ if (value)
+ value->attachStamp(*this);
+ setDirty(true);
}
void
setField(getFieldNumber(name), value);
}
+void
+HLAFixedRecordDataElement::_setStamp(Stamp* stamp)
+{
+ HLAAbstractFixedRecordDataElement::_setStamp(stamp);
+ for (FieldVector::iterator i = _fieldVector.begin(); i != _fieldVector.end(); ++i) {
+ if (!i->valid())
+ continue;
+ (*i)->attachStamp(*this);
+ }
+}
+
}