1 // Copyright (C) 2009 - 2010 Mathias Froehlich - Mathias.Froehlich@web.de
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #ifndef HLAFixedRecordDataElement_hxx
19 #define HLAFixedRecordDataElement_hxx
23 #include "HLADataElement.hxx"
24 #include "HLAFixedRecordDataType.hxx"
28 class HLAAbstractFixedRecordDataElement : public HLADataElement {
30 HLAAbstractFixedRecordDataElement(const HLAFixedRecordDataType* dataType);
31 virtual ~HLAAbstractFixedRecordDataElement();
33 virtual bool decode(HLADecodeStream& stream);
34 virtual bool encode(HLAEncodeStream& stream) const;
36 virtual const HLAFixedRecordDataType* getDataType() const;
37 virtual bool setDataType(const HLADataType* dataType);
38 void setDataType(const HLAFixedRecordDataType* dataType);
40 unsigned getNumFields() const;
41 unsigned getFieldNumber(const std::string& name) const;
43 const HLADataType* getFieldDataType(unsigned i) const;
44 const HLADataType* getFieldDataType(const std::string& name) const;
46 virtual bool decodeField(HLADecodeStream& stream, unsigned i) = 0;
47 virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const = 0;
50 SGSharedPtr<const HLAFixedRecordDataType> _dataType;
53 class HLAFixedRecordDataElement : public HLAAbstractFixedRecordDataElement {
55 HLAFixedRecordDataElement(const HLAFixedRecordDataType* dataType);
56 virtual ~HLAFixedRecordDataElement();
58 virtual bool decodeField(HLADecodeStream& stream, unsigned i);
59 virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const;
61 HLADataElement* getField(const std::string& name);
62 const HLADataElement* getField(const std::string& name) const;
64 HLADataElement* getField(unsigned i);
65 const HLADataElement* getField(unsigned i) const;
67 void setField(unsigned index, HLADataElement* value);
68 void setField(const std::string& name, HLADataElement* value);
71 typedef std::vector<SGSharedPtr<HLADataElement> > FieldVector;
72 FieldVector _fieldVector;