X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fhla%2FHLAFederate.hxx;h=be052130178ff0bf5afa6e91dc9541eef877aabd;hb=32ef925a79c323880fb0cfb4209aca8486467d17;hp=0775a566ca04d49e8c3467568f4151e4f6506555;hpb=5708ec5a89ff21868068a67815cd2771b96c11c4;p=simgear.git diff --git a/simgear/hla/HLAFederate.hxx b/simgear/hla/HLAFederate.hxx index 0775a566..be052130 100644 --- a/simgear/hla/HLAFederate.hxx +++ b/simgear/hla/HLAFederate.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009 - 2011 Mathias Froehlich - Mathias.Froehlich@web.de +// Copyright (C) 2009 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public @@ -44,6 +44,7 @@ public: /// The rti version backend to connect Version getVersion() const; bool setVersion(HLAFederate::Version version); + bool setVersion(const std::string& version); /// The rti backends connect arguments, depends on the version const std::list& getConnectArguments() const; @@ -161,7 +162,7 @@ public: /// a pending time advance is granted. bool processMessages(); - /// Legacy tick call + /// Legacy tick call - deprecated bool tick(const double& minimum, const double& maximum); class ObjectModelFactory { @@ -170,7 +171,7 @@ public: { } virtual HLAObjectClass* createObjectClass(const std::string& name, HLAFederate& federate) - { return new HLAObjectClass(name, federate); } + { return federate.createObjectClass(name); } virtual bool subscribeObjectClass(const std::string& objectClassName, const std::string& sharing) { return sharing.find("Subscribe") != std::string::npos; } virtual bool publishObjectClass(const std::string& objectClassName, const std::string& sharing) @@ -182,20 +183,56 @@ public: }; - /// Read an omt xml file + /// Read an omt xml file - deprecated bool readObjectModelTemplate(const std::string& objectModel, ObjectModelFactory& objectModelFactory); - HLAObjectClass* getObjectClass(const std::string& name); - const HLAObjectClass* getObjectClass(const std::string& name) const; + /// Read an rti1.3 omt xml file + bool readRTI13ObjectModelTemplate(const std::string& objectModel); + /// Read an rti1516 omt xml file + bool readRTI1516ObjectModelTemplate(const std::string& objectModel); + /// Read an rti1516e omt xml file + bool readRTI1516EObjectModelTemplate(const std::string& objectModel); + + /// Is called past a successful join to populate the rti classes + bool resolveObjectModel(); + + /// Access data types + const HLADataType* getDataType(const std::string& name) const; + // virtual const HLADataType* createDataType(const std::string& name); + bool insertDataType(const std::string& name, const SGSharedPtr& dataType); + void recomputeDataTypeAlignment(); + /// Get the interaction class of a given name HLAInteractionClass* getInteractionClass(const std::string& name); const HLAInteractionClass* getInteractionClass(const std::string& name) const; + /// Default create function. Creates a default interaction class + virtual HLAInteractionClass* createInteractionClass(const std::string& name); + + /// Get the object class of a given name + HLAObjectClass* getObjectClass(const std::string& name); + const HLAObjectClass* getObjectClass(const std::string& name) const; + /// Default create function. Creates a default object class + virtual HLAObjectClass* createObjectClass(const std::string& name); + + /// Get the object instance of a given name + HLAObjectInstance* getObjectInstance(const std::string& name); + const HLAObjectInstance* getObjectInstance(const std::string& name) const; + virtual HLAObjectInstance* createObjectInstance(HLAObjectClass* objectClass, const std::string& name); /// Tells the main exec loop to continue or not. void setDone(bool done); bool getDone() const; + /// The user overridable slot that is called to set up an object model + /// By default, depending on the set up rti version, the apropriate + /// bool read{RTI13,RTI1516,RTI1516E}ObjectModelTemplate(const std::string& objectModel); + /// method is called. + /// Note that the RTI13 files do not contain any information about the data types. + /// A user needs to set up the data types and assign them to the object classes/ + /// interaction classes theirselves. + /// Past reading the object model, it is still possible to change the subscription/publication + /// types without introducing traffic on the backend rti. virtual bool readObjectModel(); virtual bool subscribe(); @@ -211,6 +248,16 @@ private: HLAFederate(const HLAFederate&); HLAFederate& operator=(const HLAFederate&); + void _clearRTI(); + + /// Internal helpers for interaction classes + bool _insertInteractionClass(const SGSharedPtr& interactionClass); + /// Internal helpers for object classes + bool _insertObjectClass(const SGSharedPtr& objectClass); + /// Internal helpers for object instances + bool _insertObjectInstance(const SGSharedPtr& objectInstance); + void _eraseObjectInstance(const std::string& name); + /// The underlying interface to the rti implementation SGSharedPtr _rtiFederate; @@ -245,14 +292,27 @@ private: /// If true the exec method returns. bool _done; - typedef std::map > ObjectClassMap; - ObjectClassMap _objectClassMap; + /// The Data Types by name + typedef std::map > DataTypeMap; + DataTypeMap _dataTypeMap; + /// The Interaction Classes by name typedef std::map > InteractionClassMap; InteractionClassMap _interactionClassMap; + /// The Object Classes by name + typedef std::map > ObjectClassMap; + ObjectClassMap _objectClassMap; + + /// The Object Instances by name + typedef std::map > ObjectInstanceMap; + ObjectInstanceMap _objectInstanceMap; + /// The Object Instances by name, the ones that have an explicit given name, may be not yet registered + // ObjectInstanceMap _explicitNamedObjectInstanceMap; + friend class HLAInteractionClass; friend class HLAObjectClass; + friend class HLAObjectInstance; }; } // namespace simgear