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 HLAFederate_hxx
19 #define HLAFederate_hxx
23 #include "HLAObjectInstance.hxx"
24 #include "HLAObjectClass.hxx"
25 #include "HLAInteractionClass.hxx"
33 class HLAFederate : public SGWeakReferenced {
35 virtual ~HLAFederate();
37 /// Get the name of the joined federate/federation
38 const std::string& getFederateType() const;
39 const std::string& getFederationName() const;
41 /// Create a federation execution
42 /// Semantically this methods should be static,
43 /// but the nonstatic case could reuse the connection to the server
44 /// FIXME: cannot determine from the return value if we created the execution
45 bool createFederationExecution(const std::string& federation, const std::string& objectModel);
46 bool destroyFederationExecution(const std::string& federation);
48 /// Join with federateType the federation execution
49 bool join(const std::string& federateType, const std::string& federation);
52 bool enableTimeConstrained();
53 bool disableTimeConstrained();
55 bool enableTimeRegulation(const SGTimeStamp& lookahead);
56 bool disableTimeRegulation();
58 bool timeAdvanceRequestBy(const SGTimeStamp& dt);
59 bool timeAdvanceRequest(const SGTimeStamp& dt);
63 bool tick(const double& minimum, const double& maximum);
65 class ObjectModelFactory {
67 virtual ~ObjectModelFactory()
70 virtual HLAObjectClass* createObjectClass(const std::string& name, HLAFederate& federate)
71 { return new HLAObjectClass(name, federate); }
72 virtual bool subscribeObjectClass(const std::string& objectClassName, const std::string& sharing)
73 { return sharing.find("Subscribe") != std::string::npos; }
74 virtual bool publishObjectClass(const std::string& objectClassName, const std::string& sharing)
75 { return sharing.find("Publish") != std::string::npos; }
76 virtual bool subscribeAttribute(const std::string& objectClassName, const std::string& attributeName, const std::string& sharing)
77 { return sharing.find("Subscribe") != std::string::npos; }
78 virtual bool publishAttribute(const std::string& objectClassName, const std::string& attributeName, const std::string& sharing)
79 { return sharing.find("Publish") != std::string::npos; }
83 /// Read an omt xml file
84 bool readObjectModelTemplate(const std::string& objectModel,
85 ObjectModelFactory& objectModelFactory);
87 HLAObjectClass* getObjectClass(const std::string& name);
88 const HLAObjectClass* getObjectClass(const std::string& name) const;
90 HLAInteractionClass* getInteractionClass(const std::string& name);
91 const HLAInteractionClass* getInteractionClass(const std::string& name) const;
94 HLAFederate(const SGSharedPtr<RTIFederate>& rtiFederate);
97 SGSharedPtr<RTIFederate> _rtiFederate;
99 typedef std::map<std::string, SGSharedPtr<HLAObjectClass> > ObjectClassMap;
100 ObjectClassMap _objectClassMap;
102 typedef std::map<std::string, SGSharedPtr<HLAInteractionClass> > InteractionClassMap;
103 InteractionClassMap _interactionClassMap;
105 friend class HLAInteractionClass;
106 friend class HLAObjectClass;
109 } // namespace simgear