QTimer< T > Class Template Reference

List of all members.


Detailed Description

template<class T>
class QTimer< T >

execute a callback when a timeout expires

Author:
Sergio Di Domizio

Public Types

typedef void(T::* PtrToMethod )(void)
 use typedef to avoid complex syntax: this allow to refer to a pointer to a generic method of class T using simply PtrToMethod instead of writing every time void (T::*)(void)

Public Member Functions

 QTimer ()
 default constructor. timeout is set to 0 ms
 QTimer (unsigned long timeoutMs)
 constructor with timeout
virtual ~QTimer ()
 dtor
void Start ()
 start timer
void Stop ()
 stop timer
void SetTimeout (unsigned long timeoutMs)
 set timeout
void SetSingleShot (bool singleShot)
 toggle whether the timer should run only once or if it should restarted automatically when it expires
void Connect (PtrToMethod mPtr, T *objPtr)
 connect method of the template class to be executed when timeout expires

Private Member Functions

void Callback ()

Static Private Member Functions

static void EventEntryPoint (int fd, short event, void *arg)

Private Attributes

struct timeval fTimeout
 timeout structure used by libevent
struct event fEvent
 event struct used by libevent
PtrToMethod fMethPtr
 pointer to member function to be called when timeout expires
T * fClassPtr
 pointer to object on which callback method will be executed on
bool fSingleShot
bool fEventIsSet
 since evtimer_del() crashes when called on an event that has never been set, this variable is used to determine wether event_del() should be called or not

Constructor & Destructor Documentation

template<class T>
QTimer< T >::QTimer ( unsigned long  timeoutMs  )  [inline]

constructor with timeout

Parameters:
timeoutMs timeout in ms

References QTimer< T >::fEventIsSet, QTimerDispatcher::GetInstance(), and QTimer< T >::SetTimeout().


Member Function Documentation

template<class T>
void QTimer< T >::SetTimeout ( unsigned long  timeoutMs  )  [inline]

template<class T>
void QTimer< T >::Connect ( PtrToMethod  mPtr,
T *  objPtr 
) [inline]

connect method of the template class to be executed when timeout expires

Parameters:
PtrToMethod pointer to method to be executed
objPtr pointer to the instance of the object the method will be called on
Example: to connect the method MyClass::DoStuff() called on the class pointed by (MyClass*)myClassPtr, one should call: Connect(&Myclass::DoStuff,myClassPtr)

References QTimer< T >::fClassPtr, and QTimer< T >::fMethPtr.

Referenced by QBasePulserController::ConnectDelayTimers(), QPulserController::Init(), and QGuiPulserController::Init().


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

Generated on Tue Nov 16 10:50:08 2010 for CUORE Software by  doxygen 1.5.6