Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 22, 2010, 12:27:53 AM (14 years ago)
Author:
landauf
Message:

createExecutor() now returns a SharedPtr instead of a pointer. Adapted code that uses createExecutor() accordingly.

Location:
code/branches/consolecommands3/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/BaseObject.cc

    r7163 r7200  
    477477                if (!container)
    478478                {
    479                     ExecutorMember<BaseObject>* setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + '(' + statename + ')');
    480                     ExecutorMember<BaseObject>* getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + '(' + statename + ')');
     479                    const ExecutorMemberPtr<BaseObject>& setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + '(' + statename + ')');
     480                    const ExecutorMemberPtr<BaseObject>& getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + '(' + statename + ')');
    481481                    setfunctor->setDefaultValue(1, statename);
    482482                    getfunctor->setDefaultValue(1, statename);
  • code/branches/consolecommands3/src/libraries/core/EventIncludes.h

    r7163 r7200  
    7676
    7777#define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode) \
    78     static orxonox::ExecutorMember<classname>* xmlsetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')')->setDefaultValue(1, statename); \
    79     static orxonox::ExecutorMember<classname>* xmlgetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')')->setDefaultValue(1, statename); \
     78    static orxonox::ExecutorMemberPtr<classname> xmlsetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \
     79    static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \
     80    xmlsetfunctor##name->setDefaultValue(1, statename); \
     81    xmlgetfunctor##name->setDefaultValue(1, statename); \
    8082    XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
    8183
  • code/branches/consolecommands3/src/libraries/core/Executor.cc

    r7198 r7200  
    191191    }
    192192
    193     Executor& Executor::setDefaultValues(const MultiType& param1)
    194     {
    195         this->defaultValue_[0] = param1;
    196 
    197         return (*this);
    198     }
    199 
    200     Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2)
    201     {
    202         this->defaultValue_[0] = param1;
    203         this->defaultValue_[1] = param2;
    204 
    205         return (*this);
    206     }
    207 
    208     Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
     193    void Executor::setDefaultValues(const MultiType& param1)
     194    {
     195        this->defaultValue_[0] = param1;
     196    }
     197
     198    void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2)
     199    {
     200        this->defaultValue_[0] = param1;
     201        this->defaultValue_[1] = param2;
     202    }
     203
     204    void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
    209205    {
    210206        this->defaultValue_[0] = param1;
    211207        this->defaultValue_[1] = param2;
    212208        this->defaultValue_[2] = param3;
    213 
    214         return (*this);
    215     }
    216 
    217     Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
     209    }
     210
     211    void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
    218212    {
    219213        this->defaultValue_[0] = param1;
     
    221215        this->defaultValue_[2] = param3;
    222216        this->defaultValue_[3] = param4;
    223 
    224         return (*this);
    225     }
    226 
    227     Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
     217    }
     218
     219    void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    228220    {
    229221        this->defaultValue_[0] = param1;
     
    232224        this->defaultValue_[3] = param4;
    233225        this->defaultValue_[4] = param5;
    234 
    235         return (*this);
    236     }
    237 
    238     Executor& Executor::setDefaultValue(unsigned int index, const MultiType& param)
     226    }
     227
     228    void Executor::setDefaultValue(unsigned int index, const MultiType& param)
    239229    {
    240230        if (index < MAX_FUNCTOR_ARGUMENTS)
    241231            this->defaultValue_[index] = param;
    242 
    243         return (*this);
    244232    }
    245233
  • code/branches/consolecommands3/src/libraries/core/Executor.h

    r7198 r7200  
    8181                { return this->name_; }
    8282
    83             Executor& setDefaultValues(const MultiType& param1);
    84             Executor& setDefaultValues(const MultiType& param1, const MultiType& param2);
    85             Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
    86             Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
    87             Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
    88             Executor& setDefaultValue(unsigned int index, const MultiType& param);
     83            void setDefaultValues(const MultiType& param1);
     84            void setDefaultValues(const MultiType& param1, const MultiType& param2);
     85            void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
     86            void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
     87            void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
     88            void setDefaultValue(unsigned int index, const MultiType& param);
    8989
    9090            inline MultiType getDefaultValue(unsigned int index) const
     
    169169
    170170                this->functorMember_->setObject(object);
    171                 const MultiType& result = Executor::parse(params, success, delimiter);
     171                const MultiType& result = this->Executor::parse(params, success, delimiter);
    172172                this->functorMember_->setObjects(objects);
    173173
     
    180180
    181181                this->functorMember_->setObject(object);
    182                 const MultiType& result = Executor::parse(params, success, delimiter);
     182                const MultiType& result = this->Executor::parse(params, success, delimiter);
    183183                this->functorMember_->setObjects(objects);
    184184
     
    190190    };
    191191
    192     inline Executor* createExecutor(const FunctorPtr& functor, const std::string& name = "")
     192    inline ExecutorPtr createExecutor(const FunctorPtr& functor, const std::string& name = "")
    193193    {
    194194        return new Executor(functor, name);
     
    196196
    197197    template <class T>
    198     inline ExecutorMember<T>* createExecutor(const FunctorMemberPtr<T>& functor, const std::string& name = "")
     198    inline ExecutorMemberPtr<T> createExecutor(const FunctorMemberPtr<T>& functor, const std::string& name = "")
    199199    {
    200200        return new ExecutorMember<T>(functor, name);
    201201    }
    202202
    203     inline ExecutorStatic* createExecutor(const FunctorStaticPtr& functor, const std::string& name = "")
     203    inline ExecutorStaticPtr createExecutor(const FunctorStaticPtr& functor, const std::string& name = "")
    204204    {
    205205        return new ExecutorStatic(functor, name);
  • code/branches/consolecommands3/src/libraries/core/Thread.cc

    r6417 r7200  
    7575    }
    7676
    77     bool Thread::evaluateExecutor( Executor* executor )
     77    bool Thread::evaluateExecutor( const ExecutorPtr& executor )
    7878    {
    7979        this->isWorkingMutex_->lock();
     
    9292        {
    9393            //this->executorMutex_->lock();
    94             Executor* executor = this->executor_;
     94            ExecutorPtr executor = this->executor_;
    9595            //this->executorMutex_->unlock();
    9696            if( executor )
     
    9898                (*executor)();
    9999                this->executorMutex_->lock();
    100                 delete this->executor_;
    101100                this->executor_ = 0;
    102101                this->executorMutex_->unlock();
  • code/branches/consolecommands3/src/libraries/core/Thread.h

    r6417 r7200  
    4646        bool isWorking();
    4747        void waitUntilFinished();
    48         bool evaluateExecutor( Executor* executor );
     48        bool evaluateExecutor( const ExecutorPtr& executor );
    4949
    5050    private:
    5151        void            threadLoop();
    5252
    53         Executor     executor_;
     53        ExecutorPtr     executor_;
    5454        bool            isWorking_;
    5555        bool            stopThread_;
    5656        boost::thread*  workerThread_;
    5757        boost::mutex*   executorMutex_;
    58         boost::mutex*     isWorkingMutex_;
     58        boost::mutex*   isWorkingMutex_;
    5959        boost::mutex*   stopThreadMutex_;
    6060    };
  • code/branches/consolecommands3/src/libraries/core/ThreadPool.cc

    r6417 r7200  
    8181    }
    8282
    83     bool ThreadPool::passFunction( Executor* executor, bool addThread )
     83    bool ThreadPool::passFunction( const ExecutorPtr& executor, bool addThread )
    8484    {
    8585        std::vector<Thread*>::iterator it;
  • code/branches/consolecommands3/src/libraries/core/ThreadPool.h

    r6417 r7200  
    4646        unsigned int setNrOfThreads( unsigned int nr );
    4747
    48         bool passFunction( Executor* executor, bool addThread=false );
     48        bool passFunction( const ExecutorPtr& executor, bool addThread=false );
    4949        void synchronise();
    5050
  • code/branches/consolecommands3/src/libraries/core/XMLPort.h

    r7189 r7200  
    7575*/
    7676#define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
    77     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
    78     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     77    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     78    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
    7979    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
    8080
     
    9494#define XMLPortParamVariable(classname, paramname, variable, xmlelement, mode) \
    9595    XMLPortVariableHelperClass xmlcontainer##variable##dummy(static_cast<void*>(&variable)); \
    96     static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##loadexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader")); \
    97     static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##saveexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" )); \
     96    static ExecutorMemberPtr<orxonox::XMLPortVariableHelperClass> xmlcontainer##variable##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader"); \
     97    static ExecutorMemberPtr<orxonox::XMLPortVariableHelperClass> xmlcontainer##variable##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" ); \
    9898    XMLPortParamGeneric(xmlcontainer##variable, classname, orxonox::XMLPortVariableHelperClass, &xmlcontainer##variable##dummy, paramname, xmlcontainer##variable##loadexecutor, xmlcontainer##variable##saveexecutor, xmlelement, mode)
    9999
     
    110110*/
    111111#define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
    112     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
    113     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     112    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     113    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
    114114    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
    115115
     
    129129*/
    130130#define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
    131     static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     131    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
    132132    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
    133133/**
     
    135135*/
    136136#define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \
    137     static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     137    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
    138138    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
    139139
     
    161161*/
    162162#define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \
    163     static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
    164     static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
     163    static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
     164    static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
    165165    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
    166166/**
     
    168168*/
    169169#define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
    170     static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
    171     static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
     170    static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
     171    static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
    172172    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
    173173
     
    249249*/
    250250#define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
    251     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
    252     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     251    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     252    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
    253253    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    254254/**
     
    256256*/
    257257#define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
    258     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
    259     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     258    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     259    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
    260260    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    261261
     
    267267*/
    268268#define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode) \
    269     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
    270     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     269    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     270    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
    271271    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
    272272/**
     
    274274*/
    275275#define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \
    276     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
    277     static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     276    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     277    static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
    278278    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
    279279
     
    348348
    349349        public:
    350             XMLPortClassParamContainer(const std::string& paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
     350            XMLPortClassParamContainer(const std::string& paramname, Identifier* identifier, const ExecutorMemberPtr<T>& loadexecutor, const ExecutorMemberPtr<T>& saveexecutor)
    351351            {
    352352                this->paramname_ = paramname;
     
    358358            ~XMLPortClassParamContainer()
    359359            {
    360                 assert(this->loadexecutor_);
    361                 delete this->loadexecutor_;
    362                 if (this->saveexecutor_)
    363                     delete this->saveexecutor_;
    364360            }
    365361
     
    479475
    480476        private:
    481             ExecutorMember<T>* loadexecutor_;
    482             ExecutorMember<T>* saveexecutor_;
     477            ExecutorMemberPtr<T> loadexecutor_;
     478            ExecutorMemberPtr<T> saveexecutor_;
    483479            ParseParams parseParams_;
    484480    };
     
    522518    {
    523519        public:
    524             XMLPortClassObjectContainer(const std::string& sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
     520            XMLPortClassObjectContainer(const std::string& sectionname, Identifier* identifier, const ExecutorMemberPtr<T>& loadexecutor, const ExecutorMemberPtr<T>& saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
    525521            {
    526522                this->sectionname_ = sectionname;
     
    536532            ~XMLPortClassObjectContainer()
    537533            {
    538                 assert(this->loadexecutor_);
    539                 delete this->loadexecutor_;
    540                 if (this->saveexecutor_)
    541                     delete this->saveexecutor_;
    542534            }
    543535
     
    553545
    554546        private:
    555             ExecutorMember<T>* loadexecutor_;
    556             ExecutorMember<T>* saveexecutor_;
     547            ExecutorMemberPtr<T> loadexecutor_;
     548            ExecutorMemberPtr<T> saveexecutor_;
    557549    };
    558550
  • code/branches/consolecommands3/src/libraries/tools/Timer.cc

    r6417 r7200  
    5454        delaytimerset.insert(delaytimer);
    5555
    56         ExecutorStatic* delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
     56        const ExecutorStaticPtr& delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
    5757        delayexecutor->setDefaultValues(delaytimer, command);
    5858        delaytimer->setTimer(delay, false, delayexecutor);
     
    9797        @param exeuctor A executor of the function to call
    9898    */
    99     Timer::Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall)
     99    Timer::Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall)
    100100    {
    101101        this->init();
     
    103103
    104104        this->setTimer(interval, bLoop, executor, bKillAfterCall);
    105     }
    106 
    107     /**
    108         @brief Deletes the executor.
    109     */
    110     Timer::~Timer()
    111     {
    112         this->deleteExecutor();
    113105    }
    114106
     
    138130        if (temp)
    139131            this->destroy();
    140     }
    141 
    142     /**
    143         @brief Deletes the executor.
    144     */
    145     void Timer::deleteExecutor()
    146     {
    147       if (this->executor_)
    148           delete this->executor_;
    149132    }
    150133
  • code/branches/consolecommands3/src/libraries/tools/Timer.h

    r6417 r7200  
    7878        public:
    7979            Timer();
    80             ~Timer();
    8180
    82             Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall = false);
     81            Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false);
    8382
    8483            /**
     
    8988                @param executor A executor of the function to call
    9089            */
    91             void setTimer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall = false)
     90            void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false)
    9291            {
    93                 this->deleteExecutor();
    94 
    9592                this->setInterval(interval);
    9693                this->bLoop_ = bLoop;
     
    103100
    104101            void run();
    105             void deleteExecutor();
    106102
    107103            /** @brief Starts the Timer: Function-call after 'interval' seconds. */
     
    141137            void init();
    142138
    143             Executor* executor_;  //!< The executor of the function that should be called when the time expires
     139            ExecutorPtr executor_;  //!< The executor of the function that should be called when the time expires
    144140
    145             long long interval_;  //!< The time-interval in micro seconds
    146             bool bLoop_;          //!< If true, the function gets called every 'interval' seconds
    147             bool bActive_;        //!< If true, the Timer ticks and calls the function if the time's up
    148             bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function
     141            long long interval_;    //!< The time-interval in micro seconds
     142            bool bLoop_;            //!< If true, the function gets called every 'interval' seconds
     143            bool bActive_;          //!< If true, the Timer ticks and calls the function if the time's up
     144            bool bKillAfterCall_;   //!< If true the timer gets deleted after it called the function
    149145
    150             long long time_;      //!< Internal variable, counting the time till the next function-call
     146            long long time_;        //!< Internal variable, counting the time till the next function-call
    151147    };
    152148}
  • code/branches/consolecommands3/src/modules/overlays/hud/ChatOverlay.cc

    r6417 r7200  
    9191        Timer* timer = new Timer();
    9292        this->timers_.insert(timer); // store the timer in a set to destroy it in the destructor
    93         Executor* executor = createExecutor(createFunctor(&ChatOverlay::dropMessage, this));
     93        const ExecutorPtr& executor = createExecutor(createFunctor(&ChatOverlay::dropMessage, this));
    9494        executor->setDefaultValues(timer);
    9595        timer->setTimer(this->displayTime_, false, executor, true);
  • code/branches/consolecommands3/src/orxonox/gametypes/Dynamicmatch.cc

    r7163 r7200  
    155155                    spaceship->getEngine()->setSpeedFactor(5);
    156156                    WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
    157                     new Timer(10, false, &createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this))->setDefaultValue(0, ptr), true);
     157                    ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
     158                    executor->setDefaultValue(0, ptr);
     159                    new Timer(10, false, executor, true);
    158160                }
    159161            }
     
    254256                    spaceship->getEngine()->setSpeedFactor(5);
    255257                    WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
    256                     new Timer(10, false, &createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this))->setDefaultValue(0, ptr), true);
     258                    ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
     259                    executor->setDefaultValue(0, ptr);
     260                    new Timer(10, false, executor, true);
    257261                }
    258262
  • code/branches/consolecommands3/src/orxonox/weaponsystem/Munition.cc

    r5929 r7200  
    461461        if (bUseReloadTime && (munition->reloadTime_ > 0 || munition->bStackMunition_))
    462462        {
    463             Executor* executor = createExecutor(createFunctor(&Magazine::loaded, this));
     463            const ExecutorPtr& executor = createExecutor(createFunctor(&Magazine::loaded, this));
    464464            executor->setDefaultValues(munition);
    465465
Note: See TracChangeset for help on using the changeset viewer.