MMSTimer Class Reference

The MMSTimer provides timers. More...

#include <mmstimer.h>

Inheritance diagram for MMSTimer:

List of all members.

Public Member Functions

 MMSTimer (bool singleShot=false)
 Creates a new MMSTimer.
 ~MMSTimer ()
 Destroys a MMSTimer.
bool start (unsigned int milliSeconds, unsigned int firsttime_ms=0)
 Starts timer.
bool restart ()
 Restarts timer.
bool stop ()
 Stops timer.

Public Attributes

sigc::signal< void > timeOut
 This signal emits if the timer expires.

Private Types


Private Member Functions

void threadMain ()
 Virtual main method for the thread.

Private Attributes

bool singleShot
enum MMSTimer:: { ... }  action
bool firsttime
__time_t secs
long int nSecs
__time_t ft_secs
long int ft_nSecs
pthread_cond_t cond
pthread_mutex_t mutex

Detailed Description

The MMSTimer provides timers.

You can use MMSTimer for repetitive or single shot timers

See also:
MMSTimer(bool singleShot). After expiration of an interval (

start(unsigned int milliSeconds)) a signal

timeOut emits. void fn1() {printf("fn1 called
);} MMSTimer *repetitiveTimer = new MMSTimer(); repetitiveTimer->timeOut->connect(sigc::ptr_fun(&fn1)); // calls every 1.5 seconds fn1() repetitiveTimer->start(1500);

void fn2({printf("fn2 called\n")}); MMSTimer *singleShotTimer = new MMSTimer(true); singleShotTimer->timeOut->connect(sigc::ptr_fun(&fn2)); // calls after 30 seconds fn2() singleShotTimer->start(30000);

Definition at line 66 of file mmstimer.h.

Member Enumeration Documentation

anonymous enum [private]


Definition at line 127 of file mmstimer.h.

Constructor & Destructor Documentation

MMSTimer::MMSTimer ( bool  singleShot = false  ) 

Creates a new MMSTimer.

singleShot If this is set to true, the timer will emit only once, else it will do it repetitive.
If singleShot is set to true, internally the thread will be stopped after the signal is emitted.

Definition at line 42 of file mmstimer.cpp.

MMSTimer::~MMSTimer (  ) 

Destroys a MMSTimer.

Definition at line 57 of file mmstimer.cpp.

Member Function Documentation

bool MMSTimer::start ( unsigned int  milliSeconds,
unsigned int  firsttime_ms = 0 

Starts timer.

milliSeconds the timer interval in milli seconds
firsttime_ms the first timeOut will be emitted after firsttime_ms milliseconds default 0 means that the first timeOut will also be emitted after milliSeconds
If the timer is stopped (see stop()), it will be restarted using restart() but with new settings.
See also:

Definition at line 70 of file mmstimer.cpp.

bool MMSTimer::restart (  ) 

Restarts timer.

A running timer stops first and no signal emits. After this a new timer starts with the full interval (milliSeconds) set with start().

See also:


Definition at line 90 of file mmstimer.cpp.

bool MMSTimer::stop (  ) 

Stops timer.

A running timer stops and no signal emits.

No signal will be emitted anymore, but internally the thread will be hold with pthread_cond_wait().
See also:

Definition at line 103 of file mmstimer.cpp.

void MMSTimer::threadMain (  )  [private, virtual]

Virtual main method for the thread.

This virtual method is empty and have to be setup with code by a derived class. The MMSThread class is only the base class and cannot be constructed.

Implements MMSThread.

Definition at line 116 of file mmstimer.cpp.

Member Data Documentation

sigc::signal<void> MMSTimer::timeOut

This signal emits if the timer expires.

Connect a function to this signal.

Definition at line 123 of file mmstimer.h.

bool MMSTimer::singleShot [private]

Definition at line 126 of file mmstimer.h.

enum { ... } MMSTimer::action [private]

bool MMSTimer::firsttime [private]

Definition at line 134 of file mmstimer.h.

__time_t MMSTimer::secs [private]

Definition at line 135 of file mmstimer.h.

long int MMSTimer::nSecs [private]

Definition at line 136 of file mmstimer.h.

__time_t MMSTimer::ft_secs [private]

Definition at line 137 of file mmstimer.h.

long int MMSTimer::ft_nSecs [private]

Definition at line 138 of file mmstimer.h.

pthread_cond_t MMSTimer::cond [private]

Definition at line 140 of file mmstimer.h.

pthread_mutex_t MMSTimer::mutex [private]

Definition at line 141 of file mmstimer.h.

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