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 >:

GNet::AbstractTimer

List of all members.

Public Types

typedef void(T::* method_type )()

Public Member Functions

 Timer (T &t, method_type m, EventHandler &exception_handler)
 Constructor.

Protected Member Functions

virtual void onTimeout ()
 Final override from GNet::AbstractTimer.
virtual void onTimeoutException (std::exception &)
 Final override from GNet::AbstractTimer.


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 EventHandler
 {
   Timer<Foo> m_timer ;
   Foo() : m_timer(*this,&Foo::onTimeout,*this) {}
   void onTimeout() {}
   void onException( std::exception & ) { throw ; }
 } ;

Definition at line 103 of file gtimer.h.


Member Typedef Documentation

template<typename T>
typedef void(T::* GNet::Timer< T >::method_type)()


Constructor & Destructor Documentation

template<typename T>
GNet::Timer< T >::Timer ( T &  t,
method_type  m,
EventHandler exception_handler 
) [inline]

Constructor.

The EventHandler reference is required in case the timeout handler throws.

Definition at line 130 of file gtimer.h.


Member Function Documentation

template<typename T>
void GNet::Timer< T >::onTimeout (  )  [inline, protected, virtual]

Final override from GNet::AbstractTimer.

Implements GNet::AbstractTimer.

Definition at line 138 of file gtimer.h.

template<typename T>
void GNet::Timer< T >::onTimeoutException ( std::exception &  e  )  [inline, protected, virtual]

Final override from GNet::AbstractTimer.

Implements GNet::AbstractTimer.

Definition at line 144 of file gtimer.h.

References GNet::EventHandler::onException().


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5