|
fw4spl
|
The Timer class provides single-shot or repetitive timers. A Timer triggers a function once after a delay, or periodically, inside the worker loop. The delay or the period is defined by the duration attribute. More...
#include <Timer.hpp>
Inheritance diagram for fwThread::Timer:
Collaboration diagram for fwThread::Timer:Public Types | |
Typedefs | |
| typedef std::shared_ptr< Timer > | sptr |
| typedef std::function< void() > | FunctionType |
| typedef std::chrono::duration< double > | TimeDurationType |
Public Member Functions | |
| virtual FWTHREAD_API void | start ()=0 |
| Starts or restarts the timer. | |
| virtual FWTHREAD_API void | stop () |
| Stops the timer and cancel all pending operations. | |
| virtual FWTHREAD_API void | setDuration (TimeDurationType duration)=0 |
| Sets time duration. | |
| template<typename F > | |
| void | setFunction (F f) |
| Sets the function to be triggered when time duration expires. | |
| virtual bool | isOneShot () const =0 |
| Returns if the timer mode is 'one shot'. | |
| virtual void | setOneShot (bool oneShot)=0 |
| Sets timer mode. | |
| virtual bool | isRunning () const =0 |
| Returns true if the timer is currently running. | |
Public Member Functions inherited from fwCore::BaseObject | |
| virtual bool | isA (const std::string &type) const |
| virtual const std::string & | getLeafClassname () const |
| return object's classname without its namespace, i.e. BaseObject | |
| virtual const std::string & | getClassname () const |
| return full object's classname with its namespace, i.e. fwCore::BaseObject | |
Protected Member Functions | |
| FWTHREAD_API | Timer () |
| Constructs a Timer. By default, a the Timer mode is repetitive. | |
| Timer (const Timer &) | |
| Copy constructor forbidden. | |
| Timer & | operator= (const Timer &) |
| Copy operator forbidden. | |
| virtual FWTHREAD_API void | updatedFunction () |
| This method is triggered when Timer's function is changed. | |
Protected Attributes | |
| FunctionType | m_function |
| Function object to execute each time the timer expires. | |
| mutable::fwCore::mt::Mutex | m_mutex |
Additional Inherited Members | |
Static Public Member Functions inherited from fwCore::BaseObject | |
| static bool | isTypeOf (const std::string &type) |
| static const std::string & | leafClassname () |
| return object's classname without its namespace, i.e. BaseObject | |
| static const std::string & | classname () |
| return object's classname without its namespace, i.e. BaseObject | |
The Timer class provides single-shot or repetitive timers. A Timer triggers a function once after a delay, or periodically, inside the worker loop. The delay or the period is defined by the duration attribute.
Timer's function must be set before starting the timer.