Index: /code/branches/consolecommands3/src/libraries/core/Executor.cc
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/Executor.cc	(revision 7191)
+++ /code/branches/consolecommands3/src/libraries/core/Executor.cc	(revision 7192)
@@ -39,8 +39,13 @@
 namespace orxonox
 {
+    int Functor::instances_s = 0;
+    int Executor::instances_s = 0;
+
     Executor::Executor(Functor* functor, const std::string& name)
     {
+        this->references_ = 0;
         this->functor_ = functor;
         this->name_ = name;
+        ++instances_s; COUT(0) << "executor ++: " << instances_s << std::endl;
     }
 
@@ -48,4 +53,5 @@
     {
         delete this->functor_;
+        --instances_s; COUT(0) << "executor --: " << instances_s << std::endl;
     }
 
Index: /code/branches/consolecommands3/src/libraries/core/Executor.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/Executor.h	(revision 7191)
+++ /code/branches/consolecommands3/src/libraries/core/Executor.h	(revision 7192)
@@ -41,4 +41,6 @@
     class _CoreExport Executor
     {
+        friend class SharedPtr<Executor>;
+
         public:
             Executor(Functor* functor, const std::string& name = "");
@@ -108,4 +110,13 @@
             std::string name_;
             MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
+
+        private:
+            inline void incrementReferenceCount()
+                { ++this->references_; }
+            inline void decrementReferenceCount()
+                { --this->references_; if (this->references_ == 0) delete this; }
+
+            int references_;
+            static int instances_s;
     };
 
@@ -187,4 +198,21 @@
     };
 
+
+
+    typedef SharedPtr<Executor> ExecutorPtr;
+
+    typedef SharedChildPtr<ExecutorStatic, Executor> ExecutorStaticPtr;
+
+    template <class T>
+    class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, Executor>
+    {
+        public:
+            inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, Executor>() {}
+            inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, Executor>(pointer) {}
+//            inline ExecutorMemberPtr(const ExecutorMemberPtr& other) : SharedChildPtr<ExecutorMember<T>, Executor>(other) {}
+    };
+
+
+
     inline Executor* createExecutor(Functor* functor, const std::string& name = "")
     {
Index: /code/branches/consolecommands3/src/libraries/core/Functor.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/Functor.h	(revision 7191)
+++ /code/branches/consolecommands3/src/libraries/core/Functor.h	(revision 7192)
@@ -38,4 +38,5 @@
 #include "util/Debug.h"
 #include "util/MultiType.h"
+#include "SharedPtr.h"
 
 namespace orxonox
@@ -88,4 +89,6 @@
     class _CoreExport Functor
     {
+        friend class SharedPtr<Functor>;
+
         public:
             struct Type
@@ -101,6 +104,6 @@
 
         public:
-            Functor() {}
-            virtual ~Functor() {}
+            Functor() : references_(0) { ++instances_s; COUT(0) << "functor ++: " << instances_s << std::endl; }
+            virtual ~Functor() { --instances_s; COUT(0) << "functor --: " << instances_s << std::endl; }
 
             virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
@@ -119,4 +122,13 @@
 
             virtual const std::type_info& getHeaderIdentifier() const = 0;
+
+        private:
+            inline void incrementReferenceCount()
+                { ++this->references_; }
+            inline void decrementReferenceCount()
+                { --this->references_; if (this->references_ == 0) delete this; }
+
+            int references_;
+            static int instances_s;
     };
 
@@ -200,4 +212,19 @@
             T* object_;
             const T* constObject_;
+    };
+
+
+
+    typedef SharedPtr<Functor> FunctorPtr;
+
+    typedef SharedChildPtr<FunctorStatic, Functor> FunctorStaticPtr;
+
+    template <class T>
+    class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, Functor>
+    {
+        public:
+            inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, Functor>() {}
+            inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, Functor>(pointer) {}
+//            inline FunctorMemberPtr(const FunctorMemberPtr& other) : SharedChildPtr<FunctorMember<T>, Functor>(other) {}
     };
 
Index: /code/branches/consolecommands3/src/libraries/core/SharedPtr.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/SharedPtr.h	(revision 7192)
+++ /code/branches/consolecommands3/src/libraries/core/SharedPtr.h	(revision 7192)
@@ -0,0 +1,120 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _SharedPtr_H__
+#define _SharedPtr_H__
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+    template <class T>
+    class SharedPtr
+    {
+        public:
+            inline SharedPtr() : pointer_(0)
+            {
+//                COUT(0) << "SharedPtr (1): " << this->pointer_ << std::endl;
+            }
+
+            inline SharedPtr(T* pointer) : pointer_(pointer)
+            {
+//                COUT(0) << "SharedPtr (2): " << this->pointer_ << std::endl;
+                if (this->pointer_)
+                    this->pointer_->incrementReferenceCount();
+            }
+
+            inline SharedPtr(const SharedPtr& other) : pointer_(other.pointer_)
+            {
+//                COUT(0) << "SharedPtr (3): " << this->pointer_ << std::endl;
+                if (this->pointer_)
+                    this->pointer_->incrementReferenceCount();
+            }
+
+            inline ~SharedPtr()
+            {
+//                COUT(0) << "~SharedPtr: " << this->pointer_ << std::endl;
+                if (this->pointer_)
+                    this->pointer_->decrementReferenceCount();
+            }
+
+            inline const SharedPtr& operator=(const SharedPtr& other)
+            {
+//                COUT(0) << "SharedPtr=" << std::endl;
+                SharedPtr(other).swap(*this);
+                return *this;
+            }
+
+            inline void cast(const SharedPtr& other)
+            {
+//                COUT(0) << "SharedPtr cast" << std::endl;
+                SharedPtr(other).swap(*this);
+            }
+
+            inline T* operator->() const
+            {
+                assert(this->pointer_ != 0);
+                return this->pointer_;
+            }
+
+            inline T& operator*() const
+            {
+                assert(this->pointer_ != 0);
+                return *this->pointer_;
+            }
+
+            inline operator bool() const
+            {
+                return (this->pointer_ != 0);
+            }
+
+            inline void swap(SharedPtr& other)
+            {
+                T* temp = this->pointer_;
+                this->pointer_ = other.pointer_;
+                other.pointer_ = temp;
+            }
+
+        private:
+            T* pointer_;
+    };
+
+    template <class T, class Parent>
+    class SharedChildPtr : public SharedPtr<Parent>
+    {
+        public:
+            inline SharedChildPtr() : SharedPtr<Parent>() {}
+            inline SharedChildPtr(T* pointer) : SharedPtr<Parent>(pointer) {}
+            inline SharedChildPtr(const SharedChildPtr& other) : SharedPtr<Parent>(other) {}
+            inline const SharedChildPtr& operator=(const SharedChildPtr& other) { SharedPtr<Parent>::operator=(other); return *this; }
+            inline T* operator->() const { return static_cast<T*>(SharedPtr<Parent>::operator->()); }
+            inline T& operator*() const { return *static_cast<T*>(SharedPtr<Parent>::operator->()); }
+    };
+}
+
+#endif /* _SharedPtr_H__ */
