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 void accept(HLADataElementVisitor& visitor);
34 virtual void accept(HLAConstDataElementVisitor& visitor) const;
36 virtual bool decode(HLADecodeStream& stream);
37 virtual bool encode(HLAEncodeStream& stream) const;
39 virtual const HLAFixedRecordDataType* getDataType() const;
40 virtual bool setDataType(const HLADataType* dataType);
41 void setDataType(const HLAFixedRecordDataType* dataType);
43 unsigned getNumFields() const;
44 unsigned getFieldNumber(const std::string& name) const;
46 const HLADataType* getFieldDataType(unsigned i) const;
47 const HLADataType* getFieldDataType(const std::string& name) const;
49 virtual bool decodeField(HLADecodeStream& stream, unsigned i) = 0;
50 virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const = 0;
53 SGSharedPtr<const HLAFixedRecordDataType> _dataType;
56 class HLAFixedRecordDataElement : public HLAAbstractFixedRecordDataElement {
58 HLAFixedRecordDataElement(const HLAFixedRecordDataType* dataType);
59 virtual ~HLAFixedRecordDataElement();
61 virtual bool setDataType(const HLADataType* dataType);
63 virtual bool decodeField(HLADecodeStream& stream, unsigned i);
64 virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const;
66 HLADataElement* getField(const std::string& name);
67 const HLADataElement* getField(const std::string& name) const;
69 HLADataElement* getField(unsigned i);
70 const HLADataElement* getField(unsigned i) const;
72 void setField(unsigned index, HLADataElement* value);
73 void setField(const std::string& name, HLADataElement* value);
76 virtual void _setStamp(Stamp* stamp);
79 typedef std::vector<SGSharedPtr<HLADataElement> > FieldVector;
80 FieldVector _fieldVector;