DAQ Driver
Timer Class Reference

The Timer class Provides a generic timer. More...

#include <Driver/MessageProcessing/Timer.h>

Public Member Functions

 Timer ()
 
void start ()
 start Starts or resets the timer; More...
 
void start (uint64_t timeout)
 start Starts or resets the timer More...
 
void stop ()
 stop Stops the timer More...
 
void setCallback (const std::function< void()> &callback)
 setCallback Sets callback that is called when timeout is reached More...
 
bool isRunning () const
 isRunning Checks if the timer is running More...
 
uint64_t timeout () const
 timeout Gets the timeout in milliseconds More...
 
void setTimeout (const uint64_t &timeout)
 setTimeout Sets the timeout in milliseconds More...
 
void process ()
 process Call periodically to run the timer More...
 
bool singleShot () const
 singleShot Check if this is a single shot timer More...
 
void setSingleShot (bool singleShot)
 setSingleShot Sets if this is a singleshot timer More...
 

Private Attributes

bool m_running
 
bool m_singleShot
 
uint64_t m_timeout
 
std::function< void(void)> m_callback
 
std::chrono::system_clock::time_point m_nextTimeout
 

Detailed Description

The Timer class Provides a generic timer.

Definition at line 13 of file Timer.h.

Constructor & Destructor Documentation

◆ Timer()

Timer::Timer ( )

Definition at line 3 of file Timer.cpp.

Member Function Documentation

◆ isRunning()

bool Timer::isRunning ( ) const

isRunning Checks if the timer is running

Returns
returns true if the timer is running

Definition at line 21 of file Timer.cpp.

◆ process()

void Timer::process ( )

process Call periodically to run the timer

Definition at line 33 of file Timer.cpp.

◆ setCallback()

void Timer::setCallback ( const std::function< void()> &  callback)

setCallback Sets callback that is called when timeout is reached

Parameters
callbackcallback to call when timeout is reached

Definition at line 17 of file Timer.cpp.

◆ setSingleShot()

void Timer::setSingleShot ( bool  singleShot)

setSingleShot Sets if this is a singleshot timer

Parameters
singleShotsets if this is a single shot timer

Definition at line 48 of file Timer.cpp.

◆ setTimeout()

void Timer::setTimeout ( const uint64_t &  timeout)

setTimeout Sets the timeout in milliseconds

Parameters
timeoutthe timeout in milliseconds

Definition at line 29 of file Timer.cpp.

◆ singleShot()

bool Timer::singleShot ( ) const

singleShot Check if this is a single shot timer

Returns
returns true if this is a single shot timer

Definition at line 43 of file Timer.cpp.

◆ start() [1/2]

void Timer::start ( )

start Starts or resets the timer;

Definition at line 7 of file Timer.cpp.

◆ start() [2/2]

void Timer::start ( uint64_t  timeout)

start Starts or resets the timer

Parameters
timeoutsets timeout for timer

Definition at line 12 of file Timer.cpp.

◆ stop()

void Timer::stop ( )

stop Stops the timer

◆ timeout()

uint64_t Timer::timeout ( ) const

timeout Gets the timeout in milliseconds

Returns
The timeout in milliseconds

Definition at line 25 of file Timer.cpp.

Member Data Documentation

◆ m_callback

std::function<void(void)> Timer::m_callback
private

Definition at line 79 of file Timer.h.

◆ m_nextTimeout

std::chrono::system_clock::time_point Timer::m_nextTimeout
private

Definition at line 80 of file Timer.h.

◆ m_running

bool Timer::m_running
private

Definition at line 76 of file Timer.h.

◆ m_singleShot

bool Timer::m_singleShot
private

Definition at line 77 of file Timer.h.

◆ m_timeout

uint64_t Timer::m_timeout
private

Definition at line 78 of file Timer.h.