Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 21, 2010, 9:03:23 PM (14 years ago)
Author:
landauf
Message:

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).

Location:
code/branches/consolecommands3/src/libraries/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/CorePrereqs.h

    r7169 r7197  
    235235}
    236236
     237#include "FunctorPtr.h"
     238#include "ExecutorPtr.h"
     239
    237240// CppTcl
    238241namespace Tcl
  • code/branches/consolecommands3/src/libraries/core/ExecutorPtr.h

    r7196 r7197  
    3737    typedef SharedPtr<Executor> ExecutorPtr;
    3838
    39     typedef SharedPtr<ExecutorStatic> ExecutorStaticPtr;
     39    typedef SharedChildPtr<ExecutorStatic, ExecutorPtr> ExecutorStaticPtr;
    4040
    4141    template <class T>
    42     class ExecutorMemberPtr : public SharedPtr<ExecutorMember<T> >
     42    class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, ExecutorPtr>
    4343    {
    4444        public:
    45             inline ExecutorMemberPtr() : SharedPtr<ExecutorMember<T> >() {}
    46             inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedPtr<ExecutorMember<T> >(pointer) {}
    47 //            inline ExecutorMemberPtr(const ExecutorMemberPtr& other) : SharedPtr<ExecutorMember<T> >(other) {}
    48             template <class O>
    49             inline ExecutorMemberPtr(const SharedPtr<O>& other) : SharedPtr<ExecutorMember<T> >(other) {}
    50 /*
    51             inline const ExecutorMemberPtr& operator=(const ExecutorMemberPtr& other) { this->SharedPtr<ExecutorMember<T> >::operator=(other); return *this; }
    52             template <class O>
    53             inline const ExecutorMemberPtr& operator=(const SharedPtr<O>& other) { this->SharedPtr<ExecutorMember<T> >::operator=(other); return *this; }
    54 */
    55         private:
    56 //            inline ExecutorMemberPtr(ExecutorMember<T>* pointer, int* counter) : SharedPtr<ExecutorMember<T> >(pointer, counter) {}
     45            inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>() {}
     46            inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(pointer) {}
     47            inline ExecutorMemberPtr(const SharedPtr<ExecutorMember<T> >& other) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(other) {}
    5748    };
    58 /*
    59     typedef SharedChildPtr<ExecutorStatic, Executor> ExecutorStaticPtr;
    60 
    61     template <class T>
    62     class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, Executor>
    63     {
    64         public:
    65             inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, Executor>() {}
    66             inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, Executor>(pointer) {}
    67     };
    68 */
    6949}
    7050
  • code/branches/consolecommands3/src/libraries/core/FunctorPtr.h

    r7196 r7197  
    3737    typedef SharedPtr<Functor> FunctorPtr;
    3838
    39     typedef SharedPtr<FunctorStatic> FunctorStaticPtr;
     39    typedef SharedChildPtr<FunctorStatic, FunctorPtr> FunctorStaticPtr;
    4040
    4141    template <class T>
    42     class FunctorMemberPtr : public SharedPtr<FunctorMember<T> >
     42    class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr>
    4343    {
    4444        public:
    45             inline FunctorMemberPtr() : SharedPtr<FunctorMember<T> >() {}
    46             inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedPtr<FunctorMember<T> >(pointer) {}
    47 //            inline FunctorMemberPtr(const FunctorMemberPtr& other) : SharedPtr<FunctorMember<T> >(other) {}
     45            inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, FunctorPtr>() {}
     46            inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer) {}
     47//            inline FunctorMemberPtr(const FunctorMemberPtr& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
     48//            template <class O>
     49//            inline FunctorMemberPtr(const SharedPtr<O>& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
     50//            template <class O>
     51//            inline FunctorMemberPtr(const SharedChildPtr<O, FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
     52            inline FunctorMemberPtr(const SharedPtr<FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
     53
     54/*
     55            inline const FunctorMemberPtr& operator=(const FunctorMemberPtr& other) { this->SharedChildPtr<FunctorMember<T>, FunctorPtr>::operator=(other); return *this; }
    4856            template <class O>
    49             inline FunctorMemberPtr(const SharedPtr<O>& other) : SharedPtr<FunctorMember<T> >(other) {}
    50 /*
    51             inline const FunctorMemberPtr& operator=(const FunctorMemberPtr& other) { this->SharedPtr<FunctorMember<T> >::operator=(other); return *this; }
    52             template <class O>
    53             inline const FunctorMemberPtr& operator=(const SharedPtr<O>& other) { this->SharedPtr<FunctorMember<T> >::operator=(other); return *this; }
     57            inline const FunctorMemberPtr& operator=(const SharedPtr<O>& other) { this->SharedChildPtr<FunctorMember<T>, FunctorPtr>::operator=(other); return *this; }
    5458*/
    5559        private:
    56 //            inline FunctorMemberPtr(FunctorMember<T>* pointer, int* counter) : SharedPtr<FunctorMember<T> >(pointer, counter) {}
     60//            inline FunctorMemberPtr(FunctorMember<T>* pointer, int* counter) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer, counter) {}
    5761    };
    5862/*
  • code/branches/consolecommands3/src/libraries/core/SharedPtr.h

    r7196 r7197  
    3232#include "CorePrereqs.h"
    3333#include <algorithm>
     34#include <cassert>
    3435
    3536namespace orxonox
     
    168169            SharedPtrDestroyer* destroyer_;
    169170    };
    170 /*
     171
    171172    template <class T, class Parent>
    172     class SharedChildPtr : public SharedPtr<Parent>
     173    class SharedChildPtr : public Parent
    173174    {
    174175        public:
    175             inline SharedChildPtr() : SharedPtr<Parent>() {}
    176             inline SharedChildPtr(T* pointer) : SharedPtr<Parent>(pointer) {}
    177             inline SharedChildPtr(const SharedChildPtr& other) : SharedPtr<Parent>(other) {}
    178             inline const SharedChildPtr& operator=(const SharedChildPtr& other) { SharedPtr<Parent>::operator=(other); return *this; }
    179             inline T* operator->() const { return static_cast<T*>(SharedPtr<Parent>::operator->()); }
    180             inline T& operator*() const { return *static_cast<T*>(SharedPtr<Parent>::operator->()); }
     176            inline SharedChildPtr() : Parent() {}
     177            inline SharedChildPtr(T* pointer) : Parent(pointer) {}
     178//            inline SharedChildPtr(const SharedChildPtr& other) : Parent(other) {}
     179//            template <class O>
     180//            inline SharedChildPtr(const SharedChildPtr<O, T>& other) : Parent(other) {}
     181            inline SharedChildPtr(const SharedPtr<T>& other) : Parent(other) {}
     182
     183//            inline const SharedChildPtr& operator=(const SharedChildPtr& other) { Parent::operator=(other); return *this; }
     184
     185            inline T* operator->() const { return static_cast<T*>(Parent::operator->()); }
     186            inline T& operator*() const { return *static_cast<T*>(Parent::operator->()); }
    181187    };
    182 */
     188
    183189}
    184190
Note: See TracChangeset for help on using the changeset viewer.