]> git.mxchange.org Git - flightgear.git/commitdiff
hla: Avoid using deprecated readObjectModelTemplate.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Sat, 18 Feb 2012 12:35:17 +0000 (13:35 +0100)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Sat, 25 Feb 2012 17:01:09 +0000 (18:01 +0100)
Avoid using the now deprecated readObjectModelTemplate() method
in HLAFederate. Make more use of the available general
initialization functions in HLAFederate.

src/Network/HLA/hla.cxx
src/Network/HLA/hla.hxx

index 5f8d157310649eae1a7f5e176c0dfd9904d8858a..493f2ee307fecd74e2544a80f4ca8887b8879b52 100644 (file)
@@ -843,8 +843,16 @@ private:
     sg::HLADataElement::IndexPathPair _mpPropertiesIndexPathPair;
 };
 
+class FGHLA::Federate : public sg::HLAFederate {
+public:
+    virtual ~Federate()
+    { }
+    virtual bool readObjectModel()
+    { return readRTI1516ObjectModelTemplate(getFederationObjectModel()); }
+};
+
 FGHLA::FGHLA(const std::vector<std::string>& tokens) :
-    _hlaFederate(new simgear::HLAFederate)
+    _hlaFederate(new Federate)
 {
     if (1 < tokens.size() && !tokens[1].empty())
         set_direction(tokens[1]);
@@ -959,27 +967,15 @@ FGHLA::open()
     _hlaFederate->setFederationObjectModel(objectModel);
     _hlaFederate->setFederateType(_federate);
 
-    // Now that it is paramtrized, connect
-    if (!_hlaFederate->connect()) {
-        SG_LOG(SG_IO, SG_ALERT, "Could not connect to rti.");
-        return false;
-    }
-
-    // Try to create and join the new federation execution
-    if (!_hlaFederate->createJoinFederationExecution()) {
-        SG_LOG(SG_IO, SG_ALERT, "Could not join federation");
+    // Now that it is paramtrized, connect/join
+    if (!_hlaFederate->init()) {
+        SG_LOG(SG_IO, SG_ALERT, "Could not init the hla/rti connect.");
         return false;
     }
 
     // bool publish = get_direction() & SG_IO_OUT;
     // bool subscribe = get_direction() & SG_IO_IN;
 
-    sg::HLAFederate::ObjectModelFactory objectModelFactory;
-    if (!_hlaFederate->readObjectModelTemplate(objectModel, objectModelFactory)) {
-        SG_LOG(SG_IO, SG_ALERT, "Could not read omt file \"" << objectModel << "\"!");
-        return false;
-    }
-
     // This should be configured form a file
     XMLConfigReader::ObjectClassConfigList::const_iterator i;
     for (i = configReader.getObjectClassConfigList().begin();
@@ -1284,11 +1280,7 @@ FGHLA::close()
     }
 
     // Leave the federation and try to destroy the federation execution.
-    // Only works if no federate is joined
-    _hlaFederate->resignDestroyFederationExecution();
-
-    // throw away the HLAFederate
-    _hlaFederate->disconnect();
+    _hlaFederate->shutdown();
 
     set_enabled(false);
 
index b1f6d426973bd60448d395d3133ef87a56587f86..d843160c28b63648b2c1f1534924048e936243b9 100644 (file)
@@ -45,6 +45,7 @@ public:
 private:
     /// All the utility classes we need currently
     class XMLConfigReader;
+    class Federate;
 
     /// The configuration parameters extracted from the tokens in the constructor
     std::string _objectModelConfig;
@@ -52,7 +53,7 @@ private:
     std::string _federate;
 
     /// The toplevel rti class
-    SGSharedPtr<simgear::HLAFederate> _hlaFederate;
+    SGSharedPtr<Federate> _hlaFederate;
     /// This class that is used to send register the local instance
     SGSharedPtr<simgear::HLAObjectClass> _localAircraftClass;
     /// The local aircraft instance