mthread  0.5.1
Public Member Functions | Protected Member Functions | Private Attributes
EventHandler Class Reference

A 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 ()
 Condition to be 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.
bool loop ()
 Main loop.
virtual bool on_event ()
 Called when the even occurs.

Private Attributes

bool trigger
 Becomes true when the event occurs; returns to false when the event has been handled.

Detailed Description

A Thread that only executes when a given event occurs.


Member Function Documentation

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

Condition to be 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 if it has not.
bool EventHandler::loop ( void  ) [protected, virtual]

Main loop.

See also:
Thread::loop().

Reimplemented from Thread.

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

Called when the even occurs.

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