]> git.mxchange.org Git - simgear.git/blob - simgear/hla/HLAFixedRecordDataElement.hxx
hla: add missing file fir the last commit.
[simgear.git] / simgear / hla / HLAFixedRecordDataElement.hxx
1 // Copyright (C) 2009 - 2010  Mathias Froehlich - Mathias.Froehlich@web.de
2 //
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.
7 //
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.
12 //
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.
16 //
17
18 #ifndef HLAFixedRecordDataElement_hxx
19 #define HLAFixedRecordDataElement_hxx
20
21 #include <string>
22 #include <vector>
23 #include "HLADataElement.hxx"
24 #include "HLAFixedRecordDataType.hxx"
25
26 namespace simgear {
27
28 class HLAAbstractFixedRecordDataElement : public HLADataElement {
29 public:
30     HLAAbstractFixedRecordDataElement(const HLAFixedRecordDataType* dataType);
31     virtual ~HLAAbstractFixedRecordDataElement();
32
33     virtual bool decode(HLADecodeStream& stream);
34     virtual bool encode(HLAEncodeStream& stream) const;
35
36     virtual const HLAFixedRecordDataType* getDataType() const;
37     virtual bool setDataType(const HLADataType* dataType);
38     void setDataType(const HLAFixedRecordDataType* dataType);
39
40     unsigned getNumFields() const;
41     unsigned getFieldNumber(const std::string& name) const;
42
43     const HLADataType* getFieldDataType(unsigned i) const;
44     const HLADataType* getFieldDataType(const std::string& name) const;
45
46     virtual bool decodeField(HLADecodeStream& stream, unsigned i) = 0;
47     virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const = 0;
48
49 private:
50     SGSharedPtr<const HLAFixedRecordDataType> _dataType;
51 };
52
53 class HLAFixedRecordDataElement : public HLAAbstractFixedRecordDataElement {
54 public:
55     HLAFixedRecordDataElement(const HLAFixedRecordDataType* dataType);
56     virtual ~HLAFixedRecordDataElement();
57
58     virtual bool decodeField(HLADecodeStream& stream, unsigned i);
59     virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const;
60
61     HLADataElement* getField(const std::string& name);
62     const HLADataElement* getField(const std::string& name) const;
63
64     HLADataElement* getField(unsigned i);
65     const HLADataElement* getField(unsigned i) const;
66
67     void setField(unsigned index, HLADataElement* value);
68     void setField(const std::string& name, HLADataElement* value);
69
70 private:
71     typedef std::vector<SGSharedPtr<HLADataElement> > FieldVector;
72     FieldVector _fieldVector;
73 };
74
75 }
76
77 #endif