= HowTo: Timer = [[TracNav(TracNav/TOC_Development)]] It's possible to delay a function call by using a [wiki:Timer]. In fact it's even possible to delay a whole call including an object and several arguments. This is achievec by using an [wiki:Executor]. == Static functions == For static functions, use StaticTimer. A StaticTimer is created either in the constructor or by calling setTimer: * '''StaticTimer('''''interval, bLoop, executor''''')''' * '''setTimer('''''interval, bLoop, executor''''')''' ''interval'' is the time in seconds until the function gets executed.[[br]] ''bLoop'' is a bool. If set to true, the Timer will continue calling the function after every ''interval'' seconds.[[br]] ''executor'' is an ExecutorStatic of a static function {{{ #include "tools/Timer.h" void myFunction(); void myAdvancedFunction(int value); // Call myFunctionafter 5 seconds StaticTimer myTimer(5.0f, false, createExecutor(createFunctor(&myFunction))); // Call myAdvancedFunction(10) after 3 seconds ExectorStatic* executor = createExecutor(createFunctor(&myAdvancedFunction)); executor->setDefaultValue(0, 10.0f); // Bind the value StaticTimer myAdvancedTimer(3.0f, false, executor); }}} See [wiki:Executor#DefaultValues this] for more information about how to find values. == Member functions == For member functions you additionally have to add the object: * '''StaticTimer('''''interval, bLoop, object, executor''''')''' * '''setTimer('''''interval, bLoop, object, executor''''')''' ''interval'', ''bLoop'' and ''executor'' are like in StaticTimer (except executor has to be an ExecutorMember).[[br]] ''object'' the object on which to call the function. {{{ #include "tools/Timer.h" class MyClass { void myFunction(); }; // Create an instance of MyClass: MyClass* object = new MyClass(); // Call MyClass::myFunctionafter after 5 seconds Timer myTimer(5.0f, false, object, createExecutor(createFunctor(&MyClass::myFunction))); }}}