[Orxonox-commit 5710] r10370 - code/branches/core7/src/libraries/core/class

landauf at orxonox.net landauf at orxonox.net
Thu Apr 16 21:59:58 CEST 2015


Author: landauf
Date: 2015-04-16 21:59:58 +0200 (Thu, 16 Apr 2015)
New Revision: 10370

Modified:
   code/branches/core7/src/libraries/core/class/IdentifierManager.cc
   code/branches/core7/src/libraries/core/class/IdentifierManager.h
Log:
more checks.

Modified: code/branches/core7/src/libraries/core/class/IdentifierManager.cc
===================================================================
--- code/branches/core7/src/libraries/core/class/IdentifierManager.cc	2015-04-16 14:43:55 UTC (rev 10369)
+++ code/branches/core7/src/libraries/core/class/IdentifierManager.cc	2015-04-16 19:59:58 UTC (rev 10370)
@@ -53,6 +53,7 @@
     {
         this->hierarchyCreatingCounter_s = 0;
         this->classIDCounter_s = 0;
+        this->recordTraceForIdentifier_ = NULL;
     }
 
     /**
@@ -118,7 +119,12 @@
                 if (it->second->hasFactory())
                 {
                     this->identifierTraceOfNewObject_.clear();
+                    this->recordTraceForIdentifier_ = it->second;
+
                     Identifiable* temp = it->second->fabricate(&temporaryContext);
+
+                    this->recordTraceForIdentifier_ = NULL;
+
                     if (temp->getIdentifier() != it->second)
                         orxout(internal_error) << "Newly created object of type " << it->second->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl;
 
@@ -208,7 +214,16 @@
     void IdentifierManager::createdObject(Identifiable* identifiable)
     {
         if (this->isCreatingHierarchy())
-            this->identifierTraceOfNewObject_[identifiable].insert(identifiable->getIdentifier());
+        {
+            if (this->recordTraceForIdentifier_)
+            {
+                if (this->identifierTraceOfNewObject_[identifiable].insert(identifiable->getIdentifier()).second == false)
+                {
+                    orxout(internal_warning) << this->recordTraceForIdentifier_->getName() << " inherits two times from " <<
+                        identifiable->getIdentifier()->getName() << ". Did you forget to use virtual inheritance?" << endl;
+                }
+            }
+        }
         else
             orxout(internal_warning) << "createdObject() called outside of class hierarchy creation" << endl;
     }

Modified: code/branches/core7/src/libraries/core/class/IdentifierManager.h
===================================================================
--- code/branches/core7/src/libraries/core/class/IdentifierManager.h	2015-04-16 14:43:55 UTC (rev 10369)
+++ code/branches/core7/src/libraries/core/class/IdentifierManager.h	2015-04-16 19:59:58 UTC (rev 10370)
@@ -111,6 +111,7 @@
             /// Used while creating the object hierarchy to keep track of the identifiers of a newly created object (and all other objects that get created as
             /// a consequence of this, e.g. nested member objects).
             std::map<Identifiable*, std::set<const Identifier*> > identifierTraceOfNewObject_;
+            Identifier* recordTraceForIdentifier_; //!< The identifier for which we want to record the trace of identifiers during object creation. If null, no trace is recorded.
     };
 }
 




More information about the Orxonox-commit mailing list