From 32ef925a79c323880fb0cfb4209aca8486467d17 Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Sun, 11 Mar 2012 09:21:47 +0100 Subject: [PATCH] hla: Add convenience function to set version by string. --- simgear/hla/HLAFederate.cxx | 16 ++++++++++++++++ simgear/hla/HLAFederate.hxx | 1 + 2 files changed, 17 insertions(+) diff --git a/simgear/hla/HLAFederate.cxx b/simgear/hla/HLAFederate.cxx index 94e8b3a2..8cd173ad 100644 --- a/simgear/hla/HLAFederate.cxx +++ b/simgear/hla/HLAFederate.cxx @@ -78,6 +78,22 @@ HLAFederate::setVersion(HLAFederate::Version version) return true; } +bool +HLAFederate::setVersion(const std::string& version) +{ + if (version == "RTI13") + return setVersion(RTI13); + else if (version == "RTI1516") + return setVersion(RTI1516); + else if (version == "RTI1516E") + return setVersion(RTI1516E); + else { + /// at some time think about routing these down to the factory + SG_LOG(SG_NETWORK, SG_ALERT, "HLA: Unknown version string in HLAFederate::setVersion!"); + return false; + } +} + const std::list& HLAFederate::getConnectArguments() const { diff --git a/simgear/hla/HLAFederate.hxx b/simgear/hla/HLAFederate.hxx index eb0c8424..be052130 100644 --- a/simgear/hla/HLAFederate.hxx +++ b/simgear/hla/HLAFederate.hxx @@ -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;