]> git.mxchange.org Git - simgear.git/blobdiff - simgear/hla/HLAOMTXmlVisitor.cxx
cppbind: automatic conversion of SGReferenced derived pointers.
[simgear.git] / simgear / hla / HLAOMTXmlVisitor.cxx
index 3783cf726a9eceef22093330f69490d601a30807..ee96f8d53a3559124cb5cf6942053f14f0517560 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 "HLAOMTXmlVisitor.hxx"
 
 #include <map>
@@ -172,6 +178,10 @@ HLAOMTXmlVisitor::setToFederate(HLAFederate& federate)
     unsigned numInteractionClasses = getNumInteractionClasses();
     for (unsigned i = 0; i < numInteractionClasses; ++i) {
         const InteractionClass* interactionClass = getInteractionClass(i);
+        if (federate.getInteractionClass(interactionClass->getName())) {
+            SG_LOG(SG_IO, SG_ALERT, "Not creating Interaction class \"" << interactionClass->getName() << "\" twice!.");
+            continue;
+        }
 
         SGSharedPtr<HLAInteractionClass> hlaInteractionClass;
         hlaInteractionClass = federate.createInteractionClass(interactionClass->getName());
@@ -195,6 +205,10 @@ HLAOMTXmlVisitor::setToFederate(HLAFederate& federate)
     unsigned numObjectClasses = getNumObjectClasses();
     for (unsigned i = 0; i < numObjectClasses; ++i) {
         const ObjectClass* objectClass = getObjectClass(i);
+        if (federate.getObjectClass(objectClass->getName())) {
+            SG_LOG(SG_IO, SG_ALERT, "Not creating Object class \"" << objectClass->getName() << "\" twice!.");
+            continue;
+        }
 
         SGSharedPtr<HLAObjectClass> hlaObjectClass;
         hlaObjectClass = federate.createObjectClass(objectClass->getName());
@@ -529,28 +543,26 @@ HLAOMTXmlVisitor::endXML()
         throw sg_exception("Internal parse error!");
 
     // propagate parent attributes to the derived classes
-    // Note that this preserves the order og the attributes starting from the root object
+    // Note that this preserves the order of the attributes starting from the root object
     for (ObjectClassList::const_iterator i = _objectClassList.begin(); i != _objectClassList.end(); ++i) {
         SGSharedPtr<const ObjectClass> objectClass = (*i)->_parentObjectClass;
-        while (objectClass) {
-            for (AttributeList::const_reverse_iterator j = objectClass->_attributes.rbegin();
-                 j != objectClass->_attributes.rend(); ++j) {
-                (*i)->_attributes.insert((*i)->_attributes.begin(), *j);
-            }
-            objectClass = objectClass->_parentObjectClass;
+        if (!objectClass.valid())
+            continue;
+        for (AttributeList::const_reverse_iterator j = objectClass->_attributes.rbegin();
+             j != objectClass->_attributes.rend(); ++j) {
+            (*i)->_attributes.insert((*i)->_attributes.begin(), *j);
         }
     }
 
     // propagate parent parameter to the derived interactions
-    // Note that this preserves the order og the parameters starting from the root object
+    // Note that this preserves the order of the parameters starting from the root object
     for (InteractionClassList::const_iterator i = _interactionClassList.begin(); i != _interactionClassList.end(); ++i) {
         SGSharedPtr<const InteractionClass> interactionClass = (*i)->_parentInteractionClass;
-        while (interactionClass) {
-            for (ParameterList::const_reverse_iterator j = interactionClass->_parameters.rbegin();
-                 j != interactionClass->_parameters.rend(); ++j) {
-                (*i)->_parameters.insert((*i)->_parameters.begin(), *j);
-            }
-            interactionClass = interactionClass->_parentInteractionClass;
+        if (!interactionClass.valid())
+            continue;
+        for (ParameterList::const_reverse_iterator j = interactionClass->_parameters.rbegin();
+             j != interactionClass->_parameters.rend(); ++j) {
+            (*i)->_parameters.insert((*i)->_parameters.begin(), *j);
         }
     }
 }