Orxonox  0.0.5 Codename: Arcturus
Classes | Namespaces | Functions
Timer.h File Reference

Declaration of the Timer class, used to call functions after a given time-interval. More...

#include "tools/ToolsPrereqs.h"
#include <functional>
#include "core/object/Listable.h"
#include "core/command/ExecutorPtr.h"

Go to the source code of this file.

Classes

class  orxonox::RealTimer
 RealTimer is a helper class that executes a function after a given amount of seconds in real-time. More...
 
class  orxonox::Timer
 Timer is a helper class that executes a function after a given amount of seconds in game-time. More...
 

Namespaces

 orxonox
 Die Wagnis Klasse hat die folgenden Aufgaben:
 

Functions

unsigned int orxonox::addDelayedCommand (Timer *timer, float delay, const std::string &command)
 Helper function, used by delay() and delayreal() to add a delayed command. More...
 
unsigned int orxonox::delay (float delay, const std::string &command)
 Console-command: Calls another console command after delay seconds (game time). More...
 
unsigned int orxonox::delayreal (float delay, const std::string &command)
 Console-command: Calls another console command after delay seconds (real time) More...
 
void orxonox::executeDelayedCommand (Timer *timer, const std::string &command)
 Helper function for delay(), executes the command and destroys the timer. More...
 
void orxonox::killdelay (unsigned int handle)
 Console-command: Kills a delayed command with given handle. More...
 
void orxonox::killdelays ()
 Console-command: Kills all scheduled commands that were delayed using delay(). More...
 

Detailed Description

Declaration of the Timer class, used to call functions after a given time-interval.

Timer is a helper class that executes a function after a given amount of time.

Usage:
header.h:

class MyClass
{
public:
MyClass();
void functionName();
private:
Timer myTimer;
};

source.cc:

MyClass::MyClass()
{
myTimer.setTimer(3, false, createExecutor(createFunctor(&ClassName::myFunction, this)));
}
void MyClass::myFunction()
{
orxout() << "Hello World" << endl;
}

The code in this example prints "Hello World" to the console, 3 seconds after creating an instance of MyClass.