[Orxonox-commit 4887] r9556 - in code/branches/core6/src/libraries: core network/synchronisable

landauf at orxonox.net landauf at orxonox.net
Sat Mar 23 16:34:14 CET 2013


Author: landauf
Date: 2013-03-23 16:34:14 +0100 (Sat, 23 Mar 2013)
New Revision: 9556

Modified:
   code/branches/core6/src/libraries/core/ClassFactory.h
   code/branches/core6/src/libraries/core/Identifier.cc
   code/branches/core6/src/libraries/core/Identifier.h
   code/branches/core6/src/libraries/core/SubclassIdentifier.h
   code/branches/core6/src/libraries/core/XMLPort.cc
   code/branches/core6/src/libraries/network/synchronisable/Synchronisable.cc
Log:
fabricate() should return OrxonoxClass*

Modified: code/branches/core6/src/libraries/core/ClassFactory.h
===================================================================
--- code/branches/core6/src/libraries/core/ClassFactory.h	2013-03-19 15:12:17 UTC (rev 9555)
+++ code/branches/core6/src/libraries/core/ClassFactory.h	2013-03-23 15:34:14 UTC (rev 9556)
@@ -54,7 +54,7 @@
     {
         public:
             virtual ~Factory() {};
-            virtual BaseObject* fabricate(BaseObject* creator) = 0;
+            virtual OrxonoxClass* fabricate(BaseObject* creator) = 0;
     };
 
     // ###############################
@@ -81,9 +81,9 @@
                 @brief Creates and returns a new object of class T.
                 @return The new object
             */
-            inline BaseObject* fabricate(BaseObject* creator)
+            inline OrxonoxClass* fabricate(BaseObject* creator)
             {
-                return static_cast<BaseObject*>(new T(creator));
+                return static_cast<OrxonoxClass*>(new T(creator));
             }
     };
 }

Modified: code/branches/core6/src/libraries/core/Identifier.cc
===================================================================
--- code/branches/core6/src/libraries/core/Identifier.cc	2013-03-19 15:12:17 UTC (rev 9555)
+++ code/branches/core6/src/libraries/core/Identifier.cc	2013-03-23 15:34:14 UTC (rev 9556)
@@ -197,7 +197,7 @@
             // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
             if (it->second->hasFactory())
             {
-                BaseObject* temp = it->second->fabricate(0);
+                OrxonoxClass* temp = it->second->fabricate(0);
                 temp->destroy();
             }
         }
@@ -233,11 +233,11 @@
         @brief Creates an object of the type the Identifier belongs to.
         @return The new object
     */
-    BaseObject* Identifier::fabricate(BaseObject* creator)
+    OrxonoxClass* Identifier::fabricate(BaseObject* creator)
     {
         if (this->factory_)
         {
-            return this->factory_->fabricate(creator); // We have to return a BaseObject, because we don't know the exact type.
+            return this->factory_->fabricate(creator);
         }
         else
         {

Modified: code/branches/core6/src/libraries/core/Identifier.h
===================================================================
--- code/branches/core6/src/libraries/core/Identifier.h	2013-03-19 15:12:17 UTC (rev 9555)
+++ code/branches/core6/src/libraries/core/Identifier.h	2013-03-23 15:34:14 UTC (rev 9556)
@@ -55,13 +55,13 @@
 
     object->getIdentifier()->getName();                                         // returns "MyClass"
 
-    BaseObject* other = object->getIdentifier()->fabricate(0);                  // fabricates a new instance of MyClass
+    OrxonoxClass* other = object->getIdentifier()->fabricate(0);                // fabricates a new instance of MyClass
 
 
     // iterate through all objects of type MyClass:
     ObjectListBase* objects = object->getIdentifier()->getObjects();            // get a pointer to the object-list
     int count;
-    for (Iterator<BaseObject> it = objects.begin(); it != objects.end(); ++it)  // iterate through the objects
+    for (Iterator<MyClass> it = objects.begin(); it != objects.end(); ++it)     // iterate through the objects
         ++count;
     orxout() << count << endl;                                                  // prints "2" because we created 2 instances of MyClass so far
 
@@ -132,7 +132,7 @@
             /// Returns true if the Identifier has a Factory.
             inline bool hasFactory() const { return (this->factory_ != 0); }
 
-            BaseObject* fabricate(BaseObject* creator);
+            OrxonoxClass* fabricate(BaseObject* creator);
 
             /// Returns true if the class can be loaded through XML.
             inline bool isLoadable() const { return this->bLoadable_; }

Modified: code/branches/core6/src/libraries/core/SubclassIdentifier.h
===================================================================
--- code/branches/core6/src/libraries/core/SubclassIdentifier.h	2013-03-19 15:12:17 UTC (rev 9555)
+++ code/branches/core6/src/libraries/core/SubclassIdentifier.h	2013-03-23 15:34:14 UTC (rev 9556)
@@ -52,11 +52,11 @@
 
     There are two possibilities to create an object out of a SubclassIdentifier: Either you just use
     the @c fabricate() function of the assigned Identifier through the overloaded @c operator->, which
-    returns a @c BaseObject* pointer, or you use the function of SubclassIdentifier, this time by using
+    returns a @c OrxonoxClass* pointer, or you use the function of SubclassIdentifier, this time by using
     @c operator., which returns a @c BaseClass* pointer (@a BaseClass is the baseclass specified by the
     template argument):
     @code
-    identifier->fabricate();    // calls Identifier::fabricate(), creates a SubClass, returns a BaseObject* pointer
+    identifier->fabricate();    // calls Identifier::fabricate(), creates a SubClass, returns a OrxonoxClass* pointer
 
     identifier.fabricate();     // calls SubclassIdentifier::fabricate(), creates a SubClass, returns a BaseClass* pointer
     @endcode
@@ -164,7 +164,7 @@
             /// Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T.
             T* fabricate(BaseObject* creator) const
             {
-                BaseObject* newObject = this->identifier_->fabricate(creator);
+                OrxonoxClass* newObject = this->identifier_->fabricate(creator);
 
                 // Check if the creation was successful
                 if (newObject)

Modified: code/branches/core6/src/libraries/core/XMLPort.cc
===================================================================
--- code/branches/core6/src/libraries/core/XMLPort.cc	2013-03-19 15:12:17 UTC (rev 9555)
+++ code/branches/core6/src/libraries/core/XMLPort.cc	2013-03-23 15:34:14 UTC (rev 9556)
@@ -88,7 +88,7 @@
                     {
                         orxout(verbose, context::xml) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << endl;
 
-                        BaseObject* newObject = identifier->fabricate(object);
+                        BaseObject* newObject = orxonox_cast<BaseObject*>(identifier->fabricate(object));
                         newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
 
                         if (this->bLoadBefore_)

Modified: code/branches/core6/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/core6/src/libraries/network/synchronisable/Synchronisable.cc	2013-03-19 15:12:17 UTC (rev 9555)
+++ code/branches/core6/src/libraries/network/synchronisable/Synchronisable.cc	2013-03-23 15:34:14 UTC (rev 9556)
@@ -155,7 +155,7 @@
         creator = orxonox_cast<BaseObject*>(synchronisable_creator);
     }
     assert(getSynchronisable(header.getObjectID())==0);   //make sure no object with this id exists
-    BaseObject *bo = id->fabricate(creator);
+    BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(creator));
     assert(bo);
     Synchronisable *no = orxonox_cast<Synchronisable*>(bo);
     assert(no);




More information about the Orxonox-commit mailing list