[Orxonox-commit 4192] r8863 - code/trunk/src/libraries/core

landauf at orxonox.net landauf at orxonox.net
Wed Aug 24 13:17:36 CEST 2011


Author: landauf
Date: 2011-08-24 13:17:36 +0200 (Wed, 24 Aug 2011)
New Revision: 8863

Modified:
   code/trunk/src/libraries/core/Super.h
Log:
added warning if a super-function has two possible parents. this prints a ton of warnings because of clone(), but will be fixed soon (either by moving the super-base of clone() to BaseObject or by removing it completely)

Modified: code/trunk/src/libraries/core/Super.h
===================================================================
--- code/trunk/src/libraries/core/Super.h	2011-08-23 13:05:58 UTC (rev 8862)
+++ code/trunk/src/libraries/core/Super.h	2011-08-24 11:17:36 UTC (rev 8863)
@@ -116,6 +116,8 @@
                         orxout(verbose, context::super) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << endl; \
                         ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \
                     } \
+                    else if (((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_->getParentIdentifier() != ClassIdentifier<T>::getIdentifier()) \
+                        orxout(internal_warning, context::super) << "SuperFunctionCaller for " << #functionname << " in " << ((ClassIdentifier<T>*)(*it))->getName() << " calls function of " << ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_->getParentIdentifier()->getName() << " but " << ClassIdentifier<T>::getIdentifier()->getName() << " is also possible (do you use multiple inheritance?)" << endl; \
                 } \
             } \
         }; \
@@ -186,6 +188,10 @@
                         orxout(verbose, context::super) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << endl;
                         ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>;
                     }
+
+                    // If there is already a caller, but for another parent, print a warning
+                    else if (((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_->getParentIdentifier() != ClassIdentifier<T>::getIdentifier())
+                        orxout(internal_warning, context::super) << "SuperFunctionCaller for " << #functionname << " in " << ((ClassIdentifier<T>*)(*it))->getName() << " calls function of " << ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_->getParentIdentifier()->getName() << " but " << ClassIdentifier<T>::getIdentifier()->getName() << " is also possible (do you use multiple inheritance?)" << endl;
                 }
             }
         };
@@ -346,6 +352,7 @@
                 public: \
                     virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
                     virtual ~SuperFunctionCaller_##functionname () {} \
+                    virtual Identifier* getParentIdentifier() const = 0; \
             }; \
             \
             template <class T> \
@@ -355,6 +362,11 @@
                     inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
                     { \
                     } \
+                    \
+                    Identifier* getParentIdentifier() const \
+                    { \
+                        return ClassIdentifier<T>::getIdentifier(); \
+                    } \
             }; \
             \
             template <class T> \
@@ -399,6 +411,11 @@
         #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART2 \
                                                         ; \
                     } \
+                    \
+                    Identifier* getParentIdentifier() const \
+                    { \
+                        return ClassIdentifier<T>::getIdentifier(); \
+                    } \
             };
 
         #define SUPER_CALL_ARGUMENTSfalse(...) OrxonoxClass* object
@@ -432,6 +449,7 @@
             public:
                 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;
                 virtual ~SuperFunctionCaller_##functionname () {}
+                virtual Identifier* getParentIdentifier() const = 0;
         };
 
         // Fallback if the base is pure virtual
@@ -443,6 +461,11 @@
                 inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
                 {
                 }
+
+                Identifier* getParentIdentifier() const
+                {
+                    return ClassIdentifier<T>::getIdentifier();
+                }
         };
 
         // Initializes the SuperFunctionCaller-pointer with a fallback caller in case the base function is pure virtual
@@ -486,6 +509,11 @@
                 {
                     (dynamic_cast<T*>(object))->T:: functionname ( Call the function with it's arguments );
                 }
+
+                Identifier* getParentIdentifier() const
+                {
+                    return ClassIdentifier<T>::getIdentifier();
+                }
         }
     */
 




More information about the Orxonox-commit mailing list