Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

File:
1 edited

Legend:

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

    r7186 r7198  
    8888    {
    8989        public:
    90             ConsoleCommand(Functor* functor, const std::string& name = "");
     90            ConsoleCommand(const FunctorPtr& functor, const std::string& name = "");
    9191
    9292            ConsoleCommand& description(const std::string& description);
     
    159159    };
    160160
    161     inline ConsoleCommand* createConsoleCommand(Functor* functor, const std::string& name = "")
     161    inline ConsoleCommand* createConsoleCommand(const FunctorPtr& functor, const std::string& name = "")
    162162    {
    163163        return new ConsoleCommand(functor, name);
     
    212212                    inline _ConsoleCommandManipulator& setFunction(F function, O* object, bool bForce = false)
    213213                        { if (this->command_) { this->command_->setFunctor(createFunctor(function, object), bForce); } return *this; }
    214                     inline _ConsoleCommandManipulator& setFunction(Functor* functor, bool bForce = false)
     214                    inline _ConsoleCommandManipulator& setFunction(const FunctorPtr& functor, bool bForce = false)
    215215                        { if (this->command_) { this->command_->setFunctor(functor, bForce); } return *this; }
    216216
     
    221221                    inline _ConsoleCommandManipulator& pushFunction(F function, O* object, bool bForce = false)
    222222                        { if (this->command_) { this->command_->pushFunctor(createFunctor(function, object), bForce); } return *this; }
    223                     inline _ConsoleCommandManipulator& pushFunction(Functor* functor, bool bForce = false)
     223                    inline _ConsoleCommandManipulator& pushFunction(const FunctorPtr& functor, bool bForce = false)
    224224                        { if (this->command_) { this->command_->pushFunctor(functor, bForce); } return *this; }
    225225
     
    245245
    246246        public:
    247             _ConsoleCommand(const std::string& group, const std::string& name, Functor* functor, bool bInitialized = true);
     247            _ConsoleCommand(const std::string& group, const std::string& name, const FunctorPtr& functor, bool bInitialized = true);
    248248
    249249            _ConsoleCommand& addShortcut();
     
    271271            static void registerCommand(const std::string& group, const std::string& name, _ConsoleCommand* command);
    272272
    273             bool setFunctor(Functor* functor, bool bForce = false);
    274             void pushFunctor(Functor* functor, bool bForce = false);
     273            bool setFunctor(const FunctorPtr& functor, bool bForce = false);
     274            void pushFunctor(const FunctorPtr& functor, bool bForce = false);
    275275            void popFunctor();
    276             Functor* getFunctor() const;
    277 
    278             bool functionHeaderMatches(Functor* functor) const;
     276            const FunctorPtr& getFunctor() const;
     277
     278            bool functionHeaderMatches(const FunctorPtr& functor) const;
    279279
    280280            void setObject(void* object);
     
    286286            bool bInitialized_;
    287287            const std::type_info& functionHeader_;
    288             std::stack<Functor*> functorStack_;
     288            std::stack<FunctorPtr> functorStack_;
    289289            std::stack<void*> objectStack_;
    290290    };
    291291
    292     inline _ConsoleCommand* _createConsoleCommand(const std::string& name, Functor* functor, bool bInitialized = true)
     292    inline _ConsoleCommand* _createConsoleCommand(const std::string& name, const FunctorPtr& functor, bool bInitialized = true)
    293293    {
    294294        return new _ConsoleCommand("", name, functor, bInitialized);
    295295    }
    296296
    297     inline _ConsoleCommand* _createConsoleCommand(const std::string& group, const std::string& name, Functor* functor, bool bInitialized = true)
     297    inline _ConsoleCommand* _createConsoleCommand(const std::string& group, const std::string& name, const FunctorPtr& functor, bool bInitialized = true)
    298298    {
    299299        return new _ConsoleCommand(group, name, functor, bInitialized);
Note: See TracChangeset for help on using the changeset viewer.