]> git.mxchange.org Git - simgear.git/blob - simgear/hla/RTI13ObjectInstance.hxx
hla: Use HLADataElementIndices for HLAInteractionClass.
[simgear.git] / simgear / hla / RTI13ObjectInstance.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 RTI13ObjectInstance_hxx
19 #define RTI13ObjectInstance_hxx
20
21 #include <map>
22 #include <memory>
23
24 #ifndef RTI_USES_STD_FSTREAM
25 #define RTI_USES_STD_FSTREAM
26 #endif
27
28 #include <RTI.hh>
29
30 #include <simgear/structure/SGWeakPtr.hxx>
31
32 #include "RTIObjectInstance.hxx"
33 #include "RTI13ObjectClass.hxx"
34
35 namespace simgear {
36
37 class RTI13Ambassador;
38 class RTI13ObjectClass;
39
40 typedef std::pair<RTI::AttributeHandle, RTIData> RTI13AttributeHandleDataPair;
41 typedef std::list<RTI13AttributeHandleDataPair> RTI13AttributeHandleDataPairList;
42
43 class RTI13ObjectInstance : public RTIObjectInstance {
44 public:
45     RTI13ObjectInstance(const RTI::ObjectHandle& handle, HLAObjectInstance* hlaObjectInstance, const RTI13ObjectClass* objectClass, RTI13Ambassador* ambassador);
46     virtual ~RTI13ObjectInstance();
47
48     const RTI::ObjectHandle& getHandle() const
49     { return _handle; }
50     void setHandle(const RTI::ObjectHandle& handle)
51     { _handle = handle; }
52
53     virtual const RTIObjectClass* getObjectClass() const;
54     const RTI13ObjectClass* get13ObjectClass() const;
55
56     unsigned getNumAttributes() const
57     { return get13ObjectClass()->getNumAttributes(); }
58     unsigned getAttributeIndex(const RTI::AttributeHandle& handle) const
59     { return get13ObjectClass()->getAttributeIndex(handle); }
60     RTI::AttributeHandle getAttributeHandle(unsigned index) const
61     { return get13ObjectClass()->getAttributeHandle(index); }
62
63     virtual std::string getName() const;
64
65     virtual void deleteObjectInstance(const RTIData& tag);
66     virtual void deleteObjectInstance(const SGTimeStamp& timeStamp, const RTIData& tag);
67     virtual void localDeleteObjectInstance();
68
69     void reflectAttributeValues(RTI13AttributeHandleDataPairList& attributeHandleDataPairList,
70                                 const RTIData& tag, HLAIndexList& indexPool);
71     void reflectAttributeValues(RTI13AttributeHandleDataPairList& attributeHandleDataPairList,
72                                 const SGTimeStamp& timeStamp, const RTIData& tag, HLAIndexList& indexPool);
73     virtual void requestObjectAttributeValueUpdate(const HLAIndexList& indexList);
74     void provideAttributeValueUpdate(const std::vector<RTI::AttributeHandle>& attributes);
75
76     virtual void updateAttributeValues(const RTIData& tag);
77     virtual void updateAttributeValues(const SGTimeStamp& timeStamp, const RTIData& tag);
78
79     virtual bool isAttributeOwnedByFederate(unsigned index) const;
80
81     void attributesInScope(const std::vector<RTI::AttributeHandle>& attributes);
82     void attributesOutOfScope(const std::vector<RTI::AttributeHandle>& attributes);
83
84     void turnUpdatesOnForObjectInstance(const std::vector<RTI::AttributeHandle>& attributes);
85     void turnUpdatesOffForObjectInstance(const std::vector<RTI::AttributeHandle>& attributes);
86
87     // Not yet sure what to do here. But the dispatch functions are already there
88     void requestAttributeOwnershipAssumption(const std::vector<RTI::AttributeHandle>& attributes, const RTIData& tag);
89     void attributeOwnershipDivestitureNotification(const std::vector<RTI::AttributeHandle>& attributes);
90     void attributeOwnershipAcquisitionNotification(const std::vector<RTI::AttributeHandle>& attributes);
91     void attributeOwnershipUnavailable(const std::vector<RTI::AttributeHandle>& attributes);
92     void requestAttributeOwnershipRelease(const std::vector<RTI::AttributeHandle>& attributes, const RTIData& tag);
93     void confirmAttributeOwnershipAcquisitionCancellation(const std::vector<RTI::AttributeHandle>& attributes);
94     void informAttributeOwnership(RTI::AttributeHandle attributeHandle, RTI::FederateHandle federateHandle);
95     void attributeIsNotOwned(RTI::AttributeHandle attributeHandle);
96     void attributeOwnedByRTI(RTI::AttributeHandle attributeHandle);
97
98 private:
99     RTI::ObjectHandle _handle;
100     SGSharedPtr<const RTI13ObjectClass> _objectClass;
101     SGSharedPtr<RTI13Ambassador> _ambassador;
102
103     // cached storage for updates
104     std::auto_ptr<RTI::AttributeHandleValuePairSet> _attributeValuePairSet;
105 };
106
107 }
108
109 #endif