Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 20, 2010, 2:59:20 AM (14 years ago)
Author:
landauf
Message:

Added a small SharedPtr template for use in Functor and Executor. It's an intrusive approach that requires the object to implement a reference counter. The SharedPtr is extensible to reflect the hierarchy of Functor, FunctorStatic, FunctorMember<T>, and all subclasses (same for Executor).

File:
1 edited

Legend:

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

    r7189 r7192  
    4141    class _CoreExport Executor
    4242    {
     43        friend class SharedPtr<Executor>;
     44
    4345        public:
    4446            Executor(Functor* functor, const std::string& name = "");
     
    108110            std::string name_;
    109111            MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
     112
     113        private:
     114            inline void incrementReferenceCount()
     115                { ++this->references_; }
     116            inline void decrementReferenceCount()
     117                { --this->references_; if (this->references_ == 0) delete this; }
     118
     119            int references_;
     120            static int instances_s;
    110121    };
    111122
     
    187198    };
    188199
     200
     201
     202    typedef SharedPtr<Executor> ExecutorPtr;
     203
     204    typedef SharedChildPtr<ExecutorStatic, Executor> ExecutorStaticPtr;
     205
     206    template <class T>
     207    class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, Executor>
     208    {
     209        public:
     210            inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, Executor>() {}
     211            inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, Executor>(pointer) {}
     212//            inline ExecutorMemberPtr(const ExecutorMemberPtr& other) : SharedChildPtr<ExecutorMember<T>, Executor>(other) {}
     213    };
     214
     215
     216
    189217    inline Executor* createExecutor(Functor* functor, const std::string& name = "")
    190218    {
Note: See TracChangeset for help on using the changeset viewer.