X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fhla%2FHLAFixedRecordDataType.cxx;h=aa4f10115319bdc4f4009882a306161d56c6da45;hb=7dc8bf3aa41655e8ae63a7193fe99b5a7802a6b7;hp=acec73a1a0335c8b4bcf35e4dc6c3db441789728;hpb=252a539e69bda7cf8cf0c5198f25f38b0a710ee2;p=simgear.git diff --git a/simgear/hla/HLAFixedRecordDataType.cxx b/simgear/hla/HLAFixedRecordDataType.cxx index acec73a1..aa4f1011 100644 --- a/simgear/hla/HLAFixedRecordDataType.cxx +++ b/simgear/hla/HLAFixedRecordDataType.cxx @@ -1,4 +1,4 @@ -// 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 @@ -15,6 +15,12 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + #include "HLAFixedRecordDataType.hxx" #include "HLADataTypeVisitor.hxx" @@ -43,6 +49,14 @@ HLAFixedRecordDataType::toFixedRecordDataType() const return this; } +void +HLAFixedRecordDataType::releaseDataTypeReferences() +{ + unsigned numFields = getNumFields(); + for (unsigned i = 0; i < numFields; ++i) + _fieldList[i].releaseDataTypeReferences(); +} + bool HLAFixedRecordDataType::decode(HLADecodeStream& stream, HLAAbstractFixedRecordDataElement& value) const { @@ -68,10 +82,18 @@ HLAFixedRecordDataType::encode(HLAEncodeStream& stream, const HLAAbstractFixedRe void HLAFixedRecordDataType::addField(const std::string& name, const HLADataType* dataType) { - // FIXME this only works if we do not reset the alignment to something smaller - if (getAlignment() < dataType->getAlignment()) - setAlignment(dataType->getAlignment()); _fieldList.push_back(Field(name, dataType)); } +void +HLAFixedRecordDataType::_recomputeAlignmentImplementation() +{ + unsigned alignment = 1; + for (unsigned i = 0; i < getNumFields(); ++i) { + if (const HLADataType* dataType = getFieldDataType(i)) + alignment = std::max(alignment, dataType->getAlignment()); + } + setAlignment(alignment); +} + } // namespace simgear