Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 14, 2008, 3:42:49 AM (16 years ago)
Author:
landauf
Message:

merged core2 back to trunk
there might be some errors, wasn't able to test it yet due to some strange g++ and linker behaviour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/tools/Timer.cc

    r1039 r1052  
    2727
    2828#include "OrxonoxStableHeaders.h"
     29#include "core/Executor.h"
     30#include "core/CoreIncludes.h"
     31#include "core/ConsoleCommand.h"
     32#include "core/CommandExecutor.h"
    2933#include "Timer.h"
    30 
    31 #include "core/CoreIncludes.h"
    3234
    3335namespace orxonox
    3436{
     37    ConsoleCommandShortcutExtern(delay, AccessLevel::None);
     38
     39    /**
     40        @brief Calls a console command after 'delay' seconds.
     41        @param delay The delay in seconds
     42        @param command The console command
     43    */
     44    void delay(float delay, const std::string& command)
     45    {
     46        StaticTimer *delaytimer = new StaticTimer();
     47        ExecutorStatic* delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
     48        delayexecutor->setDefaultValues(delaytimer, command);
     49        delaytimer->setTimer(delay, false, delayexecutor);
     50    }
     51
     52    /**
     53        @brief Executes the command.
     54        @param timer The timer to destroy after the command-execution
     55        @param command The command to execute
     56    */
     57    void executeDelayedCommand(StaticTimer* timer, const std::string& command)
     58    {
     59        CommandExecutor::execute(command);
     60        delete timer;
     61    }
     62
    3563    /**
    3664        @brief Constructor: Sets the default-values.
     
    4068        RegisterRootObject(TimerBase);
    4169
     70        this->executor_ = 0;
    4271        this->interval_ = 0;
    4372        this->bLoop_ = false;
     
    4574
    4675        this->time_ = 0;
     76    }
     77
     78    /**
     79        @brief Deletes the executor.
     80    */
     81    TimerBase::~TimerBase()
     82    {
     83        delete this->executor_;
     84    }
     85
     86    /**
     87        @brief Executes the executor.
     88    */
     89    void TimerBase::run() const
     90    {
     91        (*this->executor_)();
    4792    }
    4893
Note: See TracChangeset for help on using the changeset viewer.