X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fhla%2FHLAInteractionClass.cxx;h=a9693d9822067c4c75dc2e70094ce57ca307011e;hb=201cb61f842ef50a19438e3872ba22e588fa1afc;hp=b56aec4437583da63ee7ac154b22da4832abedaa;hpb=92f7445bb90442832005f4ffd6273e590ac9e059;p=simgear.git diff --git a/simgear/hla/HLAInteractionClass.cxx b/simgear/hla/HLAInteractionClass.cxx index b56aec44..a9693d98 100644 --- a/simgear/hla/HLAInteractionClass.cxx +++ b/simgear/hla/HLAInteractionClass.cxx @@ -15,6 +15,12 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + #include "HLAInteractionClass.hxx" #include @@ -55,6 +61,12 @@ HLAInteractionClass::getName() const return _name; } +const SGWeakPtr& +HLAInteractionClass::getFederate() const +{ + return _federate; +} + HLASubscriptionType HLAInteractionClass::getSubscriptionType() const { @@ -147,6 +159,44 @@ HLAInteractionClass::getIndexPathPair(const std::string& path) const return getIndexPathPair(HLADataElement::toStringPathPair(path)); } +bool +HLAInteractionClass::getDataElementIndex(HLADataElementIndex& dataElementIndex, const std::string& path) const +{ + if (path.empty()) { + SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: failed to parse empty element path!"); + return false; + } + std::string::size_type len = std::min(path.find_first_of("[."), path.size()); + unsigned index = 0; + while (index < getNumParameters()) { + if (path.compare(0, len, getParameterName(index)) == 0) + break; + ++index; + } + if (getNumParameters() <= index) { + SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: faild to parse data element index \"" << path << "\":\n" + << "Parameter \"" << path.substr(0, len) << "\" not found in object class \"" + << getName() << "\"!"); + return false; + } + if (!getParameterDataType(index)) { + SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: faild to parse data element index \"" << path << "\":\n" + << "Undefined parameter data type in variant record data type \"" + << getParameterName(index) << "\"!"); + return false; + } + dataElementIndex.push_back(index); + return getParameterDataType(index)->getDataElementIndex(dataElementIndex, path, len); +} + +HLADataElementIndex +HLAInteractionClass::getDataElementIndex(const std::string& path) const +{ + HLADataElementIndex dataElementIndex; + getDataElementIndex(dataElementIndex, path); + return dataElementIndex; +} + bool HLAInteractionClass::subscribe() {