Index: code/branches/consolecommands2/src/libraries/core/Functor.h
===================================================================
--- code/branches/consolecommands2/src/libraries/core/Functor.h	(revision 6451)
+++ code/branches/consolecommands2/src/libraries/core/Functor.h	(revision 6452)
@@ -31,8 +31,12 @@
 #define _Functor_H__
 
+#include <typeinfo>
+
 #include "CorePrereqs.h"
 
+#include "util/Convert.h"
 #include "util/Debug.h"
 #include "util/MultiType.h"
+#include "BaseObject.h"
 
 namespace orxonox
@@ -112,4 +116,13 @@
             virtual void evaluateParam(unsigned int index, MultiType& param) const = 0;
 
+            virtual void setBaseObject(BaseObject* object) {}
+            virtual void setBaseObject(const BaseObject* object) {}
+            virtual BaseObject* getBaseObject() const { return 0; }
+
+            virtual void setRawObjectPointer(void* object) {}
+            virtual void* getRawObjectPointer() const { return 0; }
+
+            virtual const std::type_info& getHeaderIdentifier() const = 0;
+
         protected:
             unsigned int numParams_;
@@ -182,4 +195,38 @@
             }
 
+            void setBaseObject(BaseObject* object)
+            {
+                this->bConstObject_ = false;
+                this->object_ = dynamic_cast<T*>(object);
+            }
+
+            void setBaseObject(const BaseObject* object)
+            {
+                this->bConstObject_ = true;
+                this->constObject_ = dynamic_cast<const T*>(object);
+            }
+
+            BaseObject* getBaseObject() const
+            {
+                if (this->bConstObject_)
+                    return const_cast<BaseObject*>(upcast<const BaseObject*>(this->constObject_));
+                else
+                    return upcast<BaseObject*>(this->object_);
+            }
+
+            void setRawObjectPointer(void* object)
+            {
+                this->bConstObject_ = false;
+                this->object_ = (T*)object;
+            }
+
+            void* getRawObjectPointer() const
+            {
+                if (this->bConstObject_)
+                    return (void*)this->constObject_;
+                else
+                    return (void*)this->object_;
+            }
+
         private:
             const T* constObject_;
@@ -187,4 +234,16 @@
             bool bConstObject_;
     };
+
+
+
+    template <int r, class R, class P1, class P2, class P3, class P4, class P5>
+    struct FunctorHeaderIdentifier {};
+
+
+
+    inline Functor* createFunctor(Functor* functor)
+    {
+        return functor;
+    }
 
 
@@ -294,4 +353,18 @@
 
 
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES(returnvalue, numparams) FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES##numparams(returnvalue)
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES0(returnvalue) <returnvalue, FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), void, void, void, void, void>
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES1(returnvalue) <returnvalue, FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, void, void, void, void>
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES2(returnvalue) <returnvalue, FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, P2, void, void, void>
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES3(returnvalue) <returnvalue, FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, P2, P3, void, void>
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES4(returnvalue) <returnvalue, FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, P2, P3, P4, void>
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES5(returnvalue) <returnvalue, FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, P2, P3, P4, P5>
+
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue) FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE##returnvalue
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE0 void
+#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE1 R
+
+
+
 #define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams
 #define FUNCTOR_EVALUATE_PARAM0
@@ -320,5 +393,4 @@
 
 
-
 #define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \
     FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
@@ -342,7 +414,12 @@
             } \
     \
-            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            void evaluateParam(unsigned int index, MultiType& param) const \
             { \
                 FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+            const std::type_info& getHeaderIdentifier() const \
+            { \
+                return typeid(FunctorHeaderIdentifier FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES(returnvalue, numparams)); \
             } \
     \
@@ -386,7 +463,12 @@
             } \
     \
-            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            void evaluateParam(unsigned int index, MultiType& param) const \
             { \
                 FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+            const std::type_info& getHeaderIdentifier() const \
+            { \
+                return typeid(FunctorHeaderIdentifier FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES(returnvalue, numparams)); \
             } \
     \
@@ -418,7 +500,12 @@
             } \
     \
-            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            void evaluateParam(unsigned int index, MultiType& param) const \
             { \
                 FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+            const std::type_info& getHeaderIdentifier() const \
+            { \
+                return typeid(FunctorHeaderIdentifier FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES(returnvalue, numparams)); \
             } \
     \
@@ -457,4 +544,5 @@
         return functor; \
     }
+
 
 
