- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | List of all members
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, EventHandler &exception_handler)
| Constructor. More...
Public Member Functions inherited from GNet::AbstractTimer
virtual | ~AbstractTimer ()
| Destructor. More...
void | startTimer (unsigned int time)
| Starts the timer. More...
void | cancelTimer ()
| Cancels the timer. More...

## Protected Member Functions
virtual void | onTimeout ()
| Final override from GNet::AbstractTimer. More...
virtual void | onTimeoutException (std::exception &)
| Final override from GNet::AbstractTimer. More...
Protected Member Functions inherited from GNet::AbstractTimer
| AbstractTimer ()
| Default constructor. More...

## 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) ()

Definition at line 106 of file gtimer.h.

## Constructor & Destructor Documentation

template<typename T>

GNet::Timer< T >::Timer | ( | T & | t,
|  | method_type | m,
|  | EventHandler & | exception_handler
| ) |  |

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 | ( |  | ) |
| 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 | ) |
| protected virtual

Final override from GNet::AbstractTimer.

Implements GNet::AbstractTimer.

Definition at line 144 of file gtimer.h.

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

- gtimer.h