[Orxonox-commit 5714] r10374 - in code/branches/core7/src/libraries/core: . class config object

landauf at orxonox.net landauf at orxonox.net
Sun Apr 19 22:04:36 CEST 2015


Author: landauf
Date: 2015-04-19 22:04:35 +0200 (Sun, 19 Apr 2015)
New Revision: 10374

Modified:
   code/branches/core7/src/libraries/core/CoreIncludes.h
   code/branches/core7/src/libraries/core/class/Identifiable.cc
   code/branches/core7/src/libraries/core/class/Identifier.cc
   code/branches/core7/src/libraries/core/class/Identifier.h
   code/branches/core7/src/libraries/core/class/OrxonoxInterface.cc
   code/branches/core7/src/libraries/core/config/Configurable.cc
   code/branches/core7/src/libraries/core/object/Listable.cc
Log:
added flag to define if a class should be used as a virtual parent (i.e. inherit with 'virtual public <classname>')

Modified: code/branches/core7/src/libraries/core/CoreIncludes.h
===================================================================
--- code/branches/core7/src/libraries/core/CoreIncludes.h	2015-04-18 11:09:33 UTC (rev 10373)
+++ code/branches/core7/src/libraries/core/CoreIncludes.h	2015-04-19 20:04:35 UTC (rev 10374)
@@ -254,6 +254,9 @@
             inline StaticallyInitializedIdentifier& inheritsFrom()
                 { this->parents_.push_back(new InheritsFromClass<T>()); return *this; }
 
+            inline StaticallyInitializedIdentifier& virtualBase()
+                { this->identifier_->setVirtualBase(true); return *this; }
+
         private:
             Identifier* identifier_;
             std::vector<InheritsFrom*> parents_;

Modified: code/branches/core7/src/libraries/core/class/Identifiable.cc
===================================================================
--- code/branches/core7/src/libraries/core/class/Identifiable.cc	2015-04-18 11:09:33 UTC (rev 10373)
+++ code/branches/core7/src/libraries/core/class/Identifiable.cc	2015-04-19 20:04:35 UTC (rev 10374)
@@ -40,7 +40,7 @@
 
 namespace orxonox
 {
-    RegisterClassNoArgs(Identifiable);
+    RegisterClassNoArgs(Identifiable).virtualBase();
 
     /**
         @brief Constructor: Sets the default values.

Modified: code/branches/core7/src/libraries/core/class/Identifier.cc
===================================================================
--- code/branches/core7/src/libraries/core/class/Identifier.cc	2015-04-18 11:09:33 UTC (rev 10373)
+++ code/branches/core7/src/libraries/core/class/Identifier.cc	2015-04-19 20:04:35 UTC (rev 10374)
@@ -55,6 +55,7 @@
         this->factory_ = 0;
         this->bInitialized_ = false;
         this->bLoadable_ = false;
+        this->bIsVirtualBase_ = false;
 
         this->bHasConfigValues_ = false;
 

Modified: code/branches/core7/src/libraries/core/class/Identifier.h
===================================================================
--- code/branches/core7/src/libraries/core/class/Identifier.h	2015-04-18 11:09:33 UTC (rev 10373)
+++ code/branches/core7/src/libraries/core/class/Identifier.h	2015-04-19 20:04:35 UTC (rev 10374)
@@ -138,6 +138,11 @@
             /// Set the class to be loadable through XML or not.
             inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
 
+            /// Returns true if child classes should inherit virtually from this class.
+            inline bool isVirtualBase() const { return this->bIsVirtualBase_; }
+            /// Defines if child classes should inherit virtually from this class.
+            inline void setVirtualBase(bool bIsVirtualBase) { this->bIsVirtualBase_ = bIsVirtualBase; }
+
             /// Returns true if the Identifier was completely initialized.
             inline bool isInitialized() const { return this->bInitialized_; }
 
@@ -217,6 +222,7 @@
 
             bool bInitialized_;                                            //!< Is true if the Identifier was completely initialized
             bool bLoadable_;                                               //!< False = it's not permitted to load the object through XML
+            bool bIsVirtualBase_;                                          //!< If true, it is recommended to inherit virtually from this class. This changes the order of initialization of child classes, thus this information is necessary to check the class hierarchy.
             std::string name_;                                             //!< The name of the class the Identifier belongs to
             Factory* factory_;                                             //!< The Factory, able to create new objects of the given class (if available)
             uint32_t networkID_;                                           //!< The network ID to identify a class through the network

Modified: code/branches/core7/src/libraries/core/class/OrxonoxInterface.cc
===================================================================
--- code/branches/core7/src/libraries/core/class/OrxonoxInterface.cc	2015-04-18 11:09:33 UTC (rev 10373)
+++ code/branches/core7/src/libraries/core/class/OrxonoxInterface.cc	2015-04-19 20:04:35 UTC (rev 10374)
@@ -31,7 +31,7 @@
 
 namespace orxonox
 {
-    RegisterClassNoArgs(OrxonoxInterface);
+    RegisterClassNoArgs(OrxonoxInterface).virtualBase();
 
     OrxonoxInterface::OrxonoxInterface()
     {

Modified: code/branches/core7/src/libraries/core/config/Configurable.cc
===================================================================
--- code/branches/core7/src/libraries/core/config/Configurable.cc	2015-04-18 11:09:33 UTC (rev 10373)
+++ code/branches/core7/src/libraries/core/config/Configurable.cc	2015-04-19 20:04:35 UTC (rev 10374)
@@ -31,7 +31,7 @@
 
 namespace orxonox
 {
-    RegisterClassNoArgs(Configurable);
+    RegisterClassNoArgs(Configurable).virtualBase();
 
     Configurable::Configurable()
     {

Modified: code/branches/core7/src/libraries/core/object/Listable.cc
===================================================================
--- code/branches/core7/src/libraries/core/object/Listable.cc	2015-04-18 11:09:33 UTC (rev 10373)
+++ code/branches/core7/src/libraries/core/object/Listable.cc	2015-04-19 20:04:35 UTC (rev 10374)
@@ -38,7 +38,7 @@
 
 namespace orxonox
 {
-    RegisterClass(Listable);
+    RegisterClass(Listable).virtualBase();
 
     /**
         @brief Constructor: Allocates space in the element list.




More information about the Orxonox-commit mailing list