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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.