]> git.mxchange.org Git - simgear.git/blobdiff - simgear/hla/HLAInteractionClass.cxx
cppbind: automatic conversion of SGReferenced derived pointers.
[simgear.git] / simgear / hla / HLAInteractionClass.cxx
index e2674d3f75d00568d8b21f82dae310ff038c2e06..c5b1cc5e5ccebc2030eda3a33bce80d82b5cff4f 100644 (file)
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+
+#include <simgear/compiler.h>
+
 #include "HLAInteractionClass.hxx"
 
 #include <simgear/debug/logstream.hxx>
@@ -134,23 +140,42 @@ HLAInteractionClass::setParameterDataType(unsigned index, const SGSharedPtr<cons
     _parameterVector[index]._dataType = dataType;
 }
 
-HLADataElement::IndexPathPair
-HLAInteractionClass::getIndexPathPair(const HLADataElement::StringPathPair& stringPathPair) const
+bool
+HLAInteractionClass::getDataElementIndex(HLADataElementIndex& dataElementIndex, const std::string& path) const
 {
-    unsigned index = getParameterIndex(stringPathPair.first);
+    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, "HLAInteractionClass::getIndexPathPair(\""
-               << HLADataElement::toString(stringPathPair)
-               << "\"): Could not resolve attribute \"" << stringPathPair.first
-               << "\" for interaction class \"" << getName() << "\"!");
+        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;
     }
-    return HLADataElement::IndexPathPair(index, stringPathPair.second);
+    dataElementIndex.push_back(index);
+    return getParameterDataType(index)->getDataElementIndex(dataElementIndex, path, len);
 }
 
-HLADataElement::IndexPathPair
-HLAInteractionClass::getIndexPathPair(const std::string& path) const
+HLADataElementIndex
+HLAInteractionClass::getDataElementIndex(const std::string& path) const
 {
-    return getIndexPathPair(HLADataElement::toStringPathPair(path));
+    HLADataElementIndex dataElementIndex;
+    getDataElementIndex(dataElementIndex, path);
+    return dataElementIndex;
 }
 
 bool