mthread 0.5
Public Member Functions | Protected Member Functions | Private Attributes

EventHandler Class Reference

Thread that only executes when a given event occurs. More...

#include <mthread.h>

Inheritance diagram for EventHandler:
Thread

List of all members.

Public Member Functions

 EventHandler ()
 Constructor.
virtual ~EventHandler ()
 Destructor.

Protected Member Functions

virtual bool condition ()
 Evaluated on each call to determine whether or not to run the event.
bool loop ()
 Main loop.
virtual bool on_event ()
 called automatically when condition() evaluates true.

Private Attributes

bool trigger
 Set to true when the condition evaluates true, returns to false when the event has been handled.

Detailed Description

Thread that only executes when a given event occurs.


Member Function Documentation

bool EventHandler::condition ( ) [protected, virtual]

Evaluated on each call to determine whether or not to run the event.

The condition will not be checked again until the on_event() function returns false.

Returns:
true if the event has occurred; false otherwise.
bool EventHandler::loop ( ) [protected, virtual]

Main loop.

See also:
Thread::loop().

Reimplemented from Thread.

bool EventHandler::on_event ( ) [protected, virtual]

called automatically when condition() evaluates true.

Returns:
true if the event hasn't been completely handled, false to wait for the next event.
Note:
This function does not necessarily have to check the kill_flag value as it will be honoured by the loop() function when the trigger value is false.

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Defines