Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 21, 2010, 4:54:29 PM (15 years ago)
Author:
landauf
Message:

Changed implementation of SharedPtr, it's now non-intrusive and uses an allocated counter instead. Hence it's possible to create an instance of SharedPtr<T> even if T is only known from a forward declaration. Also changed some parts of the code to reflect the inheritance of the underlying object pointers without using inheritance in the SharedPtr itself.

File:
1 edited

Legend:

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

    r7192 r7196  
    3838#include "util/Debug.h"
    3939#include "util/MultiType.h"
    40 #include "SharedPtr.h"
     40#include "FunctorPtr.h"
    4141
    4242namespace orxonox
     
    104104
    105105        public:
    106             Functor() : references_(0) { ++instances_s; COUT(0) << "functor ++: " << instances_s << std::endl; }
     106            Functor() { ++instances_s; COUT(0) << "functor ++: " << instances_s << std::endl; }
    107107            virtual ~Functor() { --instances_s; COUT(0) << "functor --: " << instances_s << std::endl; }
    108108
     
    124124
    125125        private:
    126             inline void incrementReferenceCount()
    127                 { ++this->references_; }
    128             inline void decrementReferenceCount()
    129                 { --this->references_; if (this->references_ == 0) delete this; }
    130 
    131             int references_;
    132126            static int instances_s;
    133127    };
     
    212206            T* object_;
    213207            const T* constObject_;
    214     };
    215 
    216 
    217 
    218     typedef SharedPtr<Functor> FunctorPtr;
    219 
    220     typedef SharedChildPtr<FunctorStatic, Functor> FunctorStaticPtr;
    221 
    222     template <class T>
    223     class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, Functor>
    224     {
    225         public:
    226             inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, Functor>() {}
    227             inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, Functor>(pointer) {}
    228 //            inline FunctorMemberPtr(const FunctorMemberPtr& other) : SharedChildPtr<FunctorMember<T>, Functor>(other) {}
    229208    };
    230209
Note: See TracChangeset for help on using the changeset viewer.