1 // Copyright (C) 2009 - 2010 Mathias Froehlich - Mathias.Froehlich@web.de
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.
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.
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.
18 #ifndef HLAObjectInstance_hxx
19 #define HLAObjectInstance_hxx
21 #include <simgear/structure/SGWeakPtr.hxx>
23 #include "HLADataElement.hxx"
29 class RTIObjectInstance;
32 class HLAObjectInstance : public SGWeakReferenced {
34 HLAObjectInstance(HLAObjectClass* objectClass);
35 HLAObjectInstance(HLAObjectClass* objectClass, RTIObjectInstance* rtiObjectInstance);
36 virtual ~HLAObjectInstance();
38 const std::string& getName() const
41 SGSharedPtr<HLAObjectClass> getObjectClass() const;
43 unsigned getNumAttributes() const;
44 unsigned getAttributeIndex(const std::string& name) const;
45 std::string getAttributeName(unsigned index) const;
47 const HLADataType* getAttributeDataType(unsigned index) const;
49 void setAttributeDataElement(unsigned index, SGSharedPtr<HLADataElement> dataElement);
50 HLADataElement* getAttributeDataElement(unsigned index);
51 const HLADataElement* getAttributeDataElement(unsigned index) const;
52 void setAttribute(unsigned index, const HLAPathElementMap& pathElementMap);
53 void setAttributes(const HLAAttributePathElementMap& attributePathElementMap);
55 void registerInstance();
56 void deleteInstance(const RTIData& tag);
58 class AttributeCallback : public SGReferenced {
60 virtual ~AttributeCallback() {}
61 // Notification about reflect and whatever TBD
62 // Hmm, don't know yet how this should look like
63 virtual void updateAttributeValues(HLAObjectInstance& objectInstance, const RTIData& tag)
66 virtual void reflectAttributeValues(HLAObjectInstance& objectInstance,
67 const RTIIndexDataPairList& dataPairList, const RTIData& tag)
69 virtual void reflectAttributeValues(HLAObjectInstance& objectInstance, const RTIIndexDataPairList& dataPairList,
70 const SGTimeStamp& timeStamp, const RTIData& tag)
71 { reflectAttributeValues(objectInstance, dataPairList, tag); }
74 void setAttributeCallback(const SGSharedPtr<AttributeCallback>& attributeCallback)
75 { _attributeCallback = attributeCallback; }
76 const SGSharedPtr<AttributeCallback>& getAttributeCallback() const
77 { return _attributeCallback; }
79 // Push the current values into the RTI
80 void updateAttributeValues(const RTIData& tag);
81 void updateAttributeValues(const SGTimeStamp& timeStamp, const RTIData& tag);
84 void removeInstance(const RTIData& tag);
85 void reflectAttributeValues(const RTIIndexDataPairList& dataPairList, const RTIData& tag);
86 void reflectAttributeValues(const RTIIndexDataPairList& dataPairList, const SGTimeStamp& timeStamp, const RTIData& tag);
87 friend class RTIObjectInstance;
88 friend class HLAObjectClass;
90 class DataElementFactoryVisitor;
94 SGWeakPtr<HLAObjectClass> _objectClass;
95 SGSharedPtr<RTIObjectInstance> _rtiObjectInstance;
96 SGSharedPtr<AttributeCallback> _attributeCallback;
99 } // namespace simgear