fw4spl
fwThread::Timer Class Referenceabstract

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< Timersptr
 
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.
 
Timeroperator= (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
 

Detailed Description

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.

Definition at line 27 of file Timer.hpp.


The documentation for this class was generated from the following files: