Move the decision which rti to use into HLAFederate.

This commit is contained in:
Mathias Froehlich
2011-08-30 21:52:40 +02:00
parent 427d6c3316
commit 29faf13afd
8 changed files with 151 additions and 100 deletions

View File

@@ -26,9 +26,6 @@ set(HLA_HEADERS
)
set(HLA_SOURCES
RTIObjectClass.cxx
RTIObjectInstance.cxx
RTIFederate.cxx
HLAArrayDataElement.cxx
HLAArrayDataType.cxx
HLABasicDataElement.cxx
@@ -51,15 +48,18 @@ set(HLA_SOURCES
simgear_component(hla hla "${HLA_SOURCES}" "${HLA_HEADERS}")
if(RTI_FOUND)
set(HLA13_HEADERS
HLA13Federate.hxx
)
set(HLA13_SOURCES
set(RTI13_SOURCES
RTI13ObjectClass.cxx
RTI13ObjectInstance.cxx
RTI13Federate.cxx
HLA13Federate.cxx
)
simgear_component(hla13 hla "${HLA13_SOURCES}" "${HLA13_HEADERS}")
set_property(TARGET sghla13 APPEND PROPERTY COMPILE_FLAGS "-I${RTI_INCLUDE_DIR}")
simgear_component(rti13 hla "${RTI13_SOURCES}" "")
set_property(TARGET sgrti13 APPEND PROPERTY COMPILE_FLAGS "-I${RTI_INCLUDE_DIR}")
endif()
set(RTI_SOURCES
RTIObjectClass.cxx
RTIObjectInstance.cxx
RTIFederate.cxx
)
simgear_component(rti hla "${RTI_SOURCES}" "")

View File

@@ -1,33 +0,0 @@
// Copyright (C) 2009 - 2010 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include "HLA13Federate.hxx"
#include "RTI13Federate.hxx"
namespace simgear {
HLA13Federate::HLA13Federate() :
HLAFederate(new RTI13Federate)
{
}
HLA13Federate::~HLA13Federate()
{
}
} // namespace simgear

View File

@@ -1,33 +0,0 @@
// Copyright (C) 2009 - 2010 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
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef HLA13Federate_hxx
#define HLA13Federate_hxx
#include "HLAFederate.hxx"
namespace simgear {
class HLA13Federate : public HLAFederate {
public:
HLA13Federate();
virtual ~HLA13Federate();
};
} // namespace simgear
#endif

View File

@@ -17,6 +17,7 @@
#include "HLAFederate.hxx"
#include "RTI13Federate.hxx"
#include "RTIFederate.hxx"
#include "RTIInteractionClass.hxx"
#include "RTIObjectClass.hxx"
@@ -26,8 +27,7 @@
namespace simgear {
HLAFederate::HLAFederate(const SGSharedPtr<RTIFederate>& rtiFederate) :
_rtiFederate(rtiFederate)
HLAFederate::HLAFederate()
{
}
@@ -35,105 +35,209 @@ HLAFederate::~HLAFederate()
{
}
const std::string&
std::string
HLAFederate::getFederateType() const
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return std::string();
}
return _rtiFederate->getFederateType();
}
const std::string&
std::string
HLAFederate::getFederationName() const
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return std::string();
}
return _rtiFederate->getFederationName();
}
bool
HLAFederate::connect(Version version, const std::list<std::string>& stringList)
{
if (_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Trying to connect to already connected federate!");
return false;
}
switch (version) {
case RTI13:
_rtiFederate = new RTI13Federate(stringList);
break;
case RTI1516:
SG_LOG(SG_IO, SG_ALERT, "HLA version RTI1516 not yet(!?) supported.");
// _rtiFederate = new RTI1516Federate(stringList);
break;
case RTI1516E:
SG_LOG(SG_IO, SG_ALERT, "HLA version RTI1516E not yet(!?) supported.");
// _rtiFederate = new RTI1516eFederate(stringList);
break;
default:
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Unknown rti version in connect!");
}
return _rtiFederate.valid();
}
bool
HLAFederate::disconnect()
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
_rtiFederate = 0;
return true;
}
bool
HLAFederate::createFederationExecution(const std::string& federation, const std::string& objectModel)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->createFederationExecution(federation, objectModel);
}
bool
HLAFederate::destroyFederationExecution(const std::string& federation)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->destroyFederationExecution(federation);
}
bool
HLAFederate::join(const std::string& federateType, const std::string& federation)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->join(federateType, federation);
}
bool
HLAFederate::resign()
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->resign();
}
bool
HLAFederate::enableTimeConstrained()
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->enableTimeConstrained();
}
bool
HLAFederate::disableTimeConstrained()
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->disableTimeConstrained();
}
bool
HLAFederate::enableTimeRegulation(const SGTimeStamp& lookahead)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->enableTimeRegulation(lookahead);
}
bool
HLAFederate::disableTimeRegulation()
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->disableTimeRegulation();
}
bool
HLAFederate::timeAdvanceRequestBy(const SGTimeStamp& dt)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->timeAdvanceRequestBy(dt);
}
bool
HLAFederate::timeAdvanceRequest(const SGTimeStamp& dt)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->timeAdvanceRequest(dt);
}
bool
HLAFederate::queryFederateTime(SGTimeStamp& timeStamp)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->queryFederateTime(timeStamp);
}
bool
HLAFederate::modifyLookahead(const SGTimeStamp& timeStamp)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->modifyLookahead(timeStamp);
}
bool
HLAFederate::queryLookahead(SGTimeStamp& timeStamp)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->queryLookahead(timeStamp);
}
bool
HLAFederate::tick()
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->tick();
}
bool
HLAFederate::tick(const double& minimum, const double& maximum)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
return _rtiFederate->tick(minimum, maximum);
}
@@ -142,8 +246,7 @@ HLAFederate::readObjectModelTemplate(const std::string& objectModel,
HLAFederate::ObjectModelFactory& objectModelFactory)
{
if (!_rtiFederate.valid()) {
SG_LOG(SG_IO, SG_ALERT, "Could not process HLA XML object model file: "
"No rti federate available!");
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}

View File

@@ -32,11 +32,22 @@ class RTIFederate;
class HLAFederate : public SGWeakReferenced {
public:
enum Version {
RTI13,
RTI1516,
RTI1516E
};
HLAFederate();
virtual ~HLAFederate();
/// connect to an rti
bool connect(Version version, const std::list<std::string>& stringList);
bool disconnect();
/// Get the name of the joined federate/federation
const std::string& getFederateType() const;
const std::string& getFederationName() const;
std::string getFederateType() const;
std::string getFederationName() const;
/// Create a federation execution
/// Semantically this methods should be static,
@@ -94,9 +105,6 @@ public:
HLAInteractionClass* getInteractionClass(const std::string& name);
const HLAInteractionClass* getInteractionClass(const std::string& name) const;
protected:
HLAFederate(const SGSharedPtr<RTIFederate>& rtiFederate);
private:
SGSharedPtr<RTIFederate> _rtiFederate;

View File

@@ -29,9 +29,6 @@ libsghla_a_HEADERS = \
HLAVariantDataType.hxx
libsghla_a_SOURCES = \
RTIObjectClass.cxx \
RTIObjectInstance.cxx \
RTIFederate.cxx \
HLAArrayDataElement.cxx \
HLAArrayDataType.cxx \
HLABasicDataElement.cxx \
@@ -53,17 +50,23 @@ libsghla_a_SOURCES = \
if ENABLE_HLA13
lib_LIBRARIES += libsghla13.a
lib_LIBRARIES += libsgrti13.a
libsghla13_adir = @includedir@/hla
libsgrti13_adir = @includedir@/hla
libsghla13_a_HEADERS = \
HLA13Federate.hxx
libsghla13_a_SOURCES = \
libsgrti13_a_SOURCES = \
RTI13ObjectClass.cxx \
RTI13ObjectInstance.cxx \
RTI13Federate.cxx \
HLA13Federate.cxx
RTI13Federate.cxx
endif
lib_LIBRARIES += libsgrti.a
libsgrti_adir = @includedir@/hla
libsgrti_a_SOURCES = \
RTIObjectClass.cxx \
RTIObjectInstance.cxx \
RTIFederate.cxx

View File

@@ -21,10 +21,13 @@
namespace simgear {
RTI13Federate::RTI13Federate() :
RTI13Federate::RTI13Federate(const std::list<std::string>& stringList) :
_tickTimeout(10),
_ambassador(new RTI13Ambassador)
{
if (stringList.empty()) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Ignoring non empty connect arguments while connecting to an RTI13 federation!");
}
}
RTI13Federate::~RTI13Federate()

View File

@@ -34,7 +34,7 @@ class RTI13Ambassador;
class RTI13Federate : public RTIFederate {
public:
RTI13Federate();
RTI13Federate(const std::list<std::string>& stringList);
virtual ~RTI13Federate();
virtual bool createFederationExecution(const std::string& federation, const std::string& objectModel);