]> git.mxchange.org Git - simgear.git/blob - simgear/hla/HLAInteractionClass.hxx
Move noise functions from scene/material to scene/util
[simgear.git] / simgear / hla / HLAInteractionClass.hxx
1 // Copyright (C) 2009 - 2012  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 HLAInteractionClass_hxx
19 #define HLAInteractionClass_hxx
20
21 #include <map>
22 #include <string>
23 #include <vector>
24
25 #include <simgear/structure/SGWeakReferenced.hxx>
26
27 #include "HLADataElement.hxx"
28 #include "HLADataType.hxx"
29 #include "HLATypes.hxx"
30
31 namespace simgear {
32
33 class RTIInteractionClass;
34 class HLADataType;
35 class HLAFederate;
36
37 class HLAInteractionClass : public SGWeakReferenced {
38 public:
39     HLAInteractionClass(const std::string& name, HLAFederate* federate);
40     virtual ~HLAInteractionClass();
41
42     const std::string& getName() const;
43
44     HLASubscriptionType getSubscriptionType() const;
45     void setSubscriptionType(HLASubscriptionType subscriptionType);
46
47     HLAPublicationType getPublicationType() const;
48     void setPublicationType(HLAPublicationType publicationType);
49
50     unsigned getNumParameters() const;
51     unsigned addParameter(const std::string& name);
52
53     unsigned getParameterIndex(const std::string& name) const;
54     std::string getParameterName(unsigned index) const;
55
56     const HLADataType* getParameterDataType(unsigned index) const;
57     void setParameterDataType(unsigned index, const SGSharedPtr<const HLADataType>& dataType);
58
59     HLADataElement::IndexPathPair getIndexPathPair(const HLADataElement::StringPathPair& stringPathPair) const;
60     HLADataElement::IndexPathPair getIndexPathPair(const std::string& path) const;
61
62     virtual bool subscribe();
63     virtual bool unsubscribe();
64
65     virtual bool publish();
66     virtual bool unpublish();
67
68 private:
69     HLAInteractionClass(const HLAInteractionClass&);
70     HLAInteractionClass& operator=(const HLAInteractionClass&);
71
72     void _setRTIInteractionClass(RTIInteractionClass* interactionClass);
73     void _resolveParameterIndex(const std::string& name, unsigned index);
74     void _clearRTIInteractionClass();
75
76     struct Parameter {
77         Parameter() {}
78         Parameter(const std::string& name) : _name(name) {}
79         std::string _name;
80         SGSharedPtr<const HLADataType> _dataType;
81     };
82     typedef std::vector<Parameter> ParameterVector;
83     typedef std::map<std::string,unsigned> NameIndexMap;
84
85     /// The parent federate.
86     SGWeakPtr<HLAFederate> _federate;
87
88     /// The rti class if already instantiated.
89     RTIInteractionClass* _rtiInteractionClass;
90
91     /// The interaction class name
92     std::string _name;
93
94     /// The configured subscription and publication type
95     HLASubscriptionType _subscriptionType;
96     HLAPublicationType _publicationType;
97
98     /// The parameter data
99     ParameterVector _parameterVector;
100     /// The mapping from parameter names to parameter indices
101     NameIndexMap _nameIndexMap;
102
103     friend class HLAFederate;
104 };
105
106 } // namespace simgear
107
108 #endif