1
0
Fork 0

hla: Avoid using deprecated readObjectModelTemplate.

Avoid using the now deprecated readObjectModelTemplate() method
in HLAFederate. Make more use of the available general
initialization functions in HLAFederate.
This commit is contained in:
Mathias Froehlich 2012-02-18 13:35:17 +01:00
parent 3b27e847b0
commit c5ddd7b1f3
2 changed files with 15 additions and 22 deletions

View 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);

View 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