[Orxonox-commit 2490] r7197 - code/branches/consolecommands3/src/libraries/core
landauf at orxonox.net
landauf at orxonox.net
Sat Aug 21 21:03:23 CEST 2010
Author: landauf
Date: 2010-08-21 21:03:23 +0200 (Sat, 21 Aug 2010)
New Revision: 7197
Modified:
code/branches/consolecommands3/src/libraries/core/CorePrereqs.h
code/branches/consolecommands3/src/libraries/core/ExecutorPtr.h
code/branches/consolecommands3/src/libraries/core/FunctorPtr.h
code/branches/consolecommands3/src/libraries/core/SharedPtr.h
Log:
Changed the implementation of SharedPtr again. I decided to represent the inheritance of the underlying object pointers by using inheritance in the SharedPtr itself (with SharedChildPtr : public SharedPtr). The previous solution led to ambiguity in functions that are overloaded for different types of SharedPtr (for example createExecutor).
Modified: code/branches/consolecommands3/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/CorePrereqs.h 2010-08-21 14:54:29 UTC (rev 7196)
+++ code/branches/consolecommands3/src/libraries/core/CorePrereqs.h 2010-08-21 19:03:23 UTC (rev 7197)
@@ -234,6 +234,9 @@
class SimpleCommand;
}
+#include "FunctorPtr.h"
+#include "ExecutorPtr.h"
+
// CppTcl
namespace Tcl
{
Modified: code/branches/consolecommands3/src/libraries/core/ExecutorPtr.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/ExecutorPtr.h 2010-08-21 14:54:29 UTC (rev 7196)
+++ code/branches/consolecommands3/src/libraries/core/ExecutorPtr.h 2010-08-21 19:03:23 UTC (rev 7197)
@@ -36,36 +36,16 @@
{
typedef SharedPtr<Executor> ExecutorPtr;
- typedef SharedPtr<ExecutorStatic> ExecutorStaticPtr;
+ typedef SharedChildPtr<ExecutorStatic, ExecutorPtr> ExecutorStaticPtr;
template <class T>
- class ExecutorMemberPtr : public SharedPtr<ExecutorMember<T> >
+ class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, ExecutorPtr>
{
public:
- inline ExecutorMemberPtr() : SharedPtr<ExecutorMember<T> >() {}
- inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedPtr<ExecutorMember<T> >(pointer) {}
-// inline ExecutorMemberPtr(const ExecutorMemberPtr& other) : SharedPtr<ExecutorMember<T> >(other) {}
- template <class O>
- inline ExecutorMemberPtr(const SharedPtr<O>& other) : SharedPtr<ExecutorMember<T> >(other) {}
-/*
- inline const ExecutorMemberPtr& operator=(const ExecutorMemberPtr& other) { this->SharedPtr<ExecutorMember<T> >::operator=(other); return *this; }
- template <class O>
- inline const ExecutorMemberPtr& operator=(const SharedPtr<O>& other) { this->SharedPtr<ExecutorMember<T> >::operator=(other); return *this; }
-*/
- private:
-// inline ExecutorMemberPtr(ExecutorMember<T>* pointer, int* counter) : SharedPtr<ExecutorMember<T> >(pointer, counter) {}
+ inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>() {}
+ inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(pointer) {}
+ inline ExecutorMemberPtr(const SharedPtr<ExecutorMember<T> >& other) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(other) {}
};
-/*
- 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) {}
- };
-*/
}
#endif /* _ExecutorPtr_H__ */
Modified: code/branches/consolecommands3/src/libraries/core/FunctorPtr.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/FunctorPtr.h 2010-08-21 14:54:29 UTC (rev 7196)
+++ code/branches/consolecommands3/src/libraries/core/FunctorPtr.h 2010-08-21 19:03:23 UTC (rev 7197)
@@ -36,24 +36,28 @@
{
typedef SharedPtr<Functor> FunctorPtr;
- typedef SharedPtr<FunctorStatic> FunctorStaticPtr;
+ typedef SharedChildPtr<FunctorStatic, FunctorPtr> FunctorStaticPtr;
template <class T>
- class FunctorMemberPtr : public SharedPtr<FunctorMember<T> >
+ class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr>
{
public:
- inline FunctorMemberPtr() : SharedPtr<FunctorMember<T> >() {}
- inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedPtr<FunctorMember<T> >(pointer) {}
-// inline FunctorMemberPtr(const FunctorMemberPtr& other) : SharedPtr<FunctorMember<T> >(other) {}
- template <class O>
- inline FunctorMemberPtr(const SharedPtr<O>& other) : SharedPtr<FunctorMember<T> >(other) {}
+ inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, FunctorPtr>() {}
+ inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer) {}
+// inline FunctorMemberPtr(const FunctorMemberPtr& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
+// template <class O>
+// inline FunctorMemberPtr(const SharedPtr<O>& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
+// template <class O>
+// inline FunctorMemberPtr(const SharedChildPtr<O, FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
+ inline FunctorMemberPtr(const SharedPtr<FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
+
/*
- inline const FunctorMemberPtr& operator=(const FunctorMemberPtr& other) { this->SharedPtr<FunctorMember<T> >::operator=(other); return *this; }
+ inline const FunctorMemberPtr& operator=(const FunctorMemberPtr& other) { this->SharedChildPtr<FunctorMember<T>, FunctorPtr>::operator=(other); return *this; }
template <class O>
- inline const FunctorMemberPtr& operator=(const SharedPtr<O>& other) { this->SharedPtr<FunctorMember<T> >::operator=(other); return *this; }
+ inline const FunctorMemberPtr& operator=(const SharedPtr<O>& other) { this->SharedChildPtr<FunctorMember<T>, FunctorPtr>::operator=(other); return *this; }
*/
private:
-// inline FunctorMemberPtr(FunctorMember<T>* pointer, int* counter) : SharedPtr<FunctorMember<T> >(pointer, counter) {}
+// inline FunctorMemberPtr(FunctorMember<T>* pointer, int* counter) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer, counter) {}
};
/*
typedef SharedChildPtr<FunctorStatic, Functor> FunctorStaticPtr;
Modified: code/branches/consolecommands3/src/libraries/core/SharedPtr.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/SharedPtr.h 2010-08-21 14:54:29 UTC (rev 7196)
+++ code/branches/consolecommands3/src/libraries/core/SharedPtr.h 2010-08-21 19:03:23 UTC (rev 7197)
@@ -31,6 +31,7 @@
#include "CorePrereqs.h"
#include <algorithm>
+#include <cassert>
namespace orxonox
{
@@ -167,19 +168,24 @@
int* counter_;
SharedPtrDestroyer* destroyer_;
};
-/*
+
template <class T, class Parent>
- class SharedChildPtr : public SharedPtr<Parent>
+ class SharedChildPtr : public 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->()); }
+ inline SharedChildPtr() : Parent() {}
+ inline SharedChildPtr(T* pointer) : Parent(pointer) {}
+// inline SharedChildPtr(const SharedChildPtr& other) : Parent(other) {}
+// template <class O>
+// inline SharedChildPtr(const SharedChildPtr<O, T>& other) : Parent(other) {}
+ inline SharedChildPtr(const SharedPtr<T>& other) : Parent(other) {}
+
+// inline const SharedChildPtr& operator=(const SharedChildPtr& other) { Parent::operator=(other); return *this; }
+
+ inline T* operator->() const { return static_cast<T*>(Parent::operator->()); }
+ inline T& operator*() const { return *static_cast<T*>(Parent::operator->()); }
};
-*/
+
}
#endif /* _SharedPtr_H__ */
More information about the Orxonox-commit
mailing list