]> git.mxchange.org Git - simgear.git/blob - simgear/hla/HLAFixedRecordDataElement.hxx
hla: Use raw pointers for HLAFederate::_insert methods.
[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 void accept(HLADataElementVisitor& visitor);
34     virtual void accept(HLAConstDataElementVisitor& visitor) const;
35
36     virtual bool decode(HLADecodeStream& stream);
37     virtual bool encode(HLAEncodeStream& stream) const;
38
39     virtual const HLAFixedRecordDataType* getDataType() const;
40     virtual bool setDataType(const HLADataType* dataType);
41     void setDataType(const HLAFixedRecordDataType* dataType);
42
43     unsigned getNumFields() const;
44     unsigned getFieldNumber(const std::string& name) const;
45
46     const HLADataType* getFieldDataType(unsigned i) const;
47     const HLADataType* getFieldDataType(const std::string& name) const;
48
49     virtual bool decodeField(HLADecodeStream& stream, unsigned i) = 0;
50     virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const = 0;
51
52 private:
53     SGSharedPtr<const HLAFixedRecordDataType> _dataType;
54 };
55
56 class HLAFixedRecordDataElement : public HLAAbstractFixedRecordDataElement {
57 public:
58     HLAFixedRecordDataElement(const HLAFixedRecordDataType* dataType);
59     virtual ~HLAFixedRecordDataElement();
60
61     virtual bool setDataType(const HLADataType* dataType);
62
63     virtual bool decodeField(HLADecodeStream& stream, unsigned i);
64     virtual bool encodeField(HLAEncodeStream& stream, unsigned i) const;
65
66     HLADataElement* getField(const std::string& name);
67     const HLADataElement* getField(const std::string& name) const;
68
69     HLADataElement* getField(unsigned i);
70     const HLADataElement* getField(unsigned i) const;
71
72     void setField(unsigned index, HLADataElement* value);
73     void setField(const std::string& name, HLADataElement* value);
74
75 protected:
76     virtual void _setStamp(Stamp* stamp);
77
78 private:
79     typedef std::vector<SGSharedPtr<HLADataElement> > FieldVector;
80     FieldVector _fieldVector;
81 };
82
83 }
84
85 #endif