VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GNet::Timer< T > Class Template Reference

A timer class template in which the timeout is delivered to the specified method. More...

#include <gtimer.h>

+ Inheritance diagram for GNet::Timer< T >:

Public Types

typedef void(T::* method_type )()
 

Public Member Functions

 Timer (T &t, method_type m, EventExceptionHandler &event_exception_handler)
 Constructor. More...
 
- Public Member Functions inherited from GNet::TimerBase
virtual ~TimerBase ()
 Destructor.
 
void startTimer (unsigned int interval_s, unsigned int interval_us=0U)
 Starts the timer so that it goes off after the given time interval. More...
 
void startTimer (const G::EpochTime &interval_time)
 Overload for an interval expressed as an G::EpochTime.
 
void cancelTimer ()
 Cancels the timer.
 
bool active () const
 Returns true if the timer is started and not cancelled.
 
bool immediate () const
 Returns true if the timer is active() and zero-length.
 

Protected Member Functions

virtual void onTimeout () override
 Override from GNet::TimerBase.
 
virtual void onException (std::exception &) override
 Override from GNet::EventExceptionHandler.
 
- Protected Member Functions inherited from GNet::TimerBase
 TimerBase ()
 Default constructor.
 
- Protected Member Functions inherited from GNet::EventExceptionHandler
virtual ~EventExceptionHandler ()
 Destructor.
 

Detailed Description

template<typename T>
class GNet::Timer< T >

A timer class template in which the timeout is delivered to the specified method.

Any exception thrown out of the timeout handler is delivered to the specified EventHandler interface so that it can be handled or rethrown.

Eg:

struct Foo : public EventExceptionHandler
{
Timer<Foo> m_timer ;
Foo() : m_timer(*this,&Foo::onTimeout,*this) {}
void onTimeout() {}
void onException( std::exception & ) { throw ; }
} ;

Definition at line 110 of file gtimer.h.

Constructor & Destructor Documentation

template<typename T>
GNet::Timer< T >::Timer ( T &  t,
method_type  m,
EventExceptionHandler event_exception_handler 
)

Constructor.

The EventExceptionHandler reference is required in case the timeout handler throws; the onException() implementation can simply rethrow to exit the event loop.

Definition at line 138 of file gtimer.h.


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