Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 21, 2010, 9:52:13 PM (15 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.cc

    r7186 r7198  
    3434namespace orxonox
    3535{
    36     ConsoleCommand::ConsoleCommand(Functor* functor, const std::string& name) : Executor(functor, name)
     36    ConsoleCommand::ConsoleCommand(const FunctorPtr& functor, const std::string& name) : Executor(functor, name)
    3737    {
    3838        this->accessLevel_ = AccessLevel::None;
     
    124124    _ConsoleCommand::_ConsoleCommandManipulator test(_ModifyConsoleCommand("BaseObject", "setName").setFunction(&BaseObject::setActive));
    125125
    126     _ConsoleCommand::_ConsoleCommand(const std::string& group, const std::string& name, Functor* functor, bool bInitialized) : Executor(functor, name), functionHeader_(functor->getHeaderIdentifier())
     126    _ConsoleCommand::_ConsoleCommand(const std::string& group, const std::string& name, const FunctorPtr& functor, bool bInitialized) : Executor(functor, name), functionHeader_(functor->getHeaderIdentifier())
    127127    {
    128128        this->bActive_ = true;
     
    155155    }
    156156
    157     bool _ConsoleCommand::setFunctor(Functor* functor, bool bForce)
     157    bool _ConsoleCommand::setFunctor(const FunctorPtr& functor, bool bForce)
    158158    {
    159159        if (!functor)
     
    174174    }
    175175
    176     void _ConsoleCommand::pushFunctor(Functor* functor, bool bForce)
    177     {
    178         Functor* oldfunctor = this->getFunctor();
     176    void _ConsoleCommand::pushFunctor(const FunctorPtr& functor, bool bForce)
     177    {
     178        const FunctorPtr& oldfunctor = this->getFunctor();
    179179
    180180        if (this->setFunctor(functor, bForce));
     
    184184    void _ConsoleCommand::popFunctor()
    185185    {
    186         Functor* newfunctor = 0;
     186        FunctorPtr newfunctor;
    187187        if (!this->functorStack_.empty())
    188188        {
     
    193193    }
    194194
    195     Functor* _ConsoleCommand::getFunctor() const
    196     {
    197         if (this->bInitialized_)
     195    const FunctorPtr& _ConsoleCommand::getFunctor() const
     196    {
     197//        if (this->bInitialized_) // FIXME
    198198            return this->functor_;
    199         else
    200             return 0;
    201     }
    202 
    203     bool _ConsoleCommand::functionHeaderMatches(Functor* functor) const
     199//        else
     200//            return 0;
     201    }
     202
     203    bool _ConsoleCommand::functionHeaderMatches(const FunctorPtr& functor) const
    204204    {
    205205        if (!this->functor_)
     
    216216            this->functor_->setRawObjectPointer(object);
    217217        else if (object)
    218             COUT(0) << "Error: Can't set object in console command \"" << this->getName() << "\", no functor set." << std::endl;
     218            COUT(1) << "Error: Can't set object in console command \"" << this->getName() << "\", no functor set." << std::endl;
    219219    }
    220220
     
    227227        }
    228228        else
    229             COUT(0) << "Error: Can't set object in console command \"" << this->getName() << "\", no functor set." << std::endl;
     229            COUT(1) << "Error: Can't set object in console command \"" << this->getName() << "\", no functor set." << std::endl;
    230230    }
    231231
     
    263263        {
    264264            if (group == "")
    265                 COUT(0) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
     265                COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
    266266            else
    267                 COUT(0) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
     267                COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
    268268        }
    269269        return 0;
Note: See TracChangeset for help on using the changeset viewer.