]> git.mxchange.org Git - simgear.git/blob - simgear/hla/RTI13ObjectInstance.hxx
hla: add missing file fir the last commit.
[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 class RTI13ObjectInstance : public RTIObjectInstance {
41 public:
42     RTI13ObjectInstance(const RTI::ObjectHandle& handle, HLAObjectInstance* hlaObjectInstance, const RTI13ObjectClass* objectClass, RTI13Ambassador* ambassador, bool owned);
43     virtual ~RTI13ObjectInstance();
44
45     const RTI::ObjectHandle& getHandle() const
46     { return _handle; }
47     void setHandle(const RTI::ObjectHandle& handle)
48     { _handle = handle; }
49
50     virtual const RTIObjectClass* getObjectClass() const;
51     const RTI13ObjectClass* get13ObjectClass() const;
52
53     unsigned getNumAttributes() const
54     { return get13ObjectClass()->getNumAttributes(); }
55     unsigned getAttributeIndex(const std::string& name) const
56     { return get13ObjectClass()->getAttributeIndex(name); }
57     unsigned getAttributeIndex(const RTI::AttributeHandle& handle) const
58     { return get13ObjectClass()->getAttributeIndex(handle); }
59     RTI::AttributeHandle getAttributeHandle(unsigned index) const
60     { return get13ObjectClass()->getAttributeHandle(index); }
61
62     virtual std::string getName() const;
63
64     virtual void deleteObjectInstance(const RTIData& tag);
65     virtual void deleteObjectInstance(const SGTimeStamp& timeStamp, const RTIData& tag);
66     virtual void localDeleteObjectInstance();
67
68     void reflectAttributeValues(const RTI::AttributeHandleValuePairSet& attributeValuePairSet, const RTIData& tag);
69     void reflectAttributeValues(const RTI::AttributeHandleValuePairSet& attributeValuePairSet, const SGTimeStamp& timeStamp, const RTIData& tag);
70     virtual void requestObjectAttributeValueUpdate();
71     void provideAttributeValueUpdate(const RTI::AttributeHandleSet& attributes);
72
73     virtual void updateAttributeValues(const RTIData& tag);
74     virtual void updateAttributeValues(const SGTimeStamp& timeStamp, const RTIData& tag);
75
76     void attributesInScope(const RTI::AttributeHandleSet& attributes);
77     void attributesOutOfScope(const RTI::AttributeHandleSet& attributes);
78
79     void turnUpdatesOnForObjectInstance(const RTI::AttributeHandleSet& attributes);
80     void turnUpdatesOffForObjectInstance(const RTI::AttributeHandleSet& attributes);
81
82     // Not yet sure what to do here. But the dispatch functions are already there
83     void requestAttributeOwnershipAssumption(const RTI::AttributeHandleSet& attributes, const RTIData& tag);
84     void attributeOwnershipDivestitureNotification(const RTI::AttributeHandleSet& attributes);
85     void attributeOwnershipAcquisitionNotification(const RTI::AttributeHandleSet& attributes);
86     void attributeOwnershipUnavailable(const RTI::AttributeHandleSet& attributes);
87     void requestAttributeOwnershipRelease(const RTI::AttributeHandleSet& attributes, const RTIData& tag);
88     void confirmAttributeOwnershipAcquisitionCancellation(const RTI::AttributeHandleSet& attributes);
89     void informAttributeOwnership(RTI::AttributeHandle attributeHandle, RTI::FederateHandle federateHandle);
90     void attributeIsNotOwned(RTI::AttributeHandle attributeHandle);
91     void attributeOwnedByRTI(RTI::AttributeHandle attributeHandle);
92
93 private:
94     RTI::ObjectHandle _handle;
95     SGSharedPtr<const RTI13ObjectClass> _objectClass;
96     SGSharedPtr<RTI13Ambassador> _ambassador;
97
98     // cached storage for updates
99     std::auto_ptr<RTI::AttributeHandleValuePairSet> _attributeValuePairSet;
100 };
101
102 }
103
104 #endif