AVRToolsPlus
A library wof higher-level tools for AVR ATmega328 and ATmega2560 Microcontrollers
|
This file provides an Event Manager using functional interface under the namespace EventManager. More...
#include <stdint.h>
Go to the source code of this file.
Namespaces | |
EventManager | |
This namespace bundles the Event Manager functionality. It provides logical cohesion for functions implement the Event Manager and prevents namespace collisions. | |
Typedefs | |
typedef void(* | EventManager::EventListener) (int eventCode, int eventParam) |
Type for an event listener (a.k.a. callback) function. | |
Enumerations | |
enum | EventManager::GenericEvents |
This enum provides common event names, purely for user convenience. | |
enum | EventManager::EventPriority |
EventManager recognizes two kinds of events. By default, events are are queued as low priority, but these constants can be used to explicitly set the priority when queueing events. More... | |
Functions | |
bool | EventManager::addListener (int eventCode, EventListener listener) |
Add an (event, listener) pair listener to the dispatch table. More... | |
bool | EventManager::removeListener (int eventCode, EventListener listener) |
Remove this (event, listener) pair from the dispatch table. Other listener pairs with the same function or event code will not be affected. More... | |
int | EventManager::removeListener (EventListener listener) |
Remove all occurrances of a listener from the dispatch table, regardless of the event code. returns number removed. More... | |
bool | EventManager::enableListener (int eventCode, EventListener listener, bool enable) |
Enable or disable an (event, listener) pair entry in the dispatch table. More... | |
bool | EventManager::isListenerEnabled (int eventCode, EventListener listener) |
Obtain the the current enabled/disabled state of an (eventCode, listener) pair. More... | |
bool | EventManager::setDefaultListener (EventListener listener) |
Set a default listener. The default listener is a callback function that is called when an event with no listener is processed. More... | |
void | EventManager::removeDefaultListener () |
Remvoes the default listener. The default listener is a callback function that is called when an event with no listener is processed. | |
void | EventManager::enableDefaultListener (bool enable) |
Enable or disable the default listener. The default listener is a callback function that is called when an event with no listener is processed. More... | |
bool | EventManager::isListenerListEmpty () |
Check if the listener list (a.k.a., dispatch table) is empty. More... | |
bool | EventManager::isListenerListFull () |
Check if the listener list (a.k.a., dispatch table) is full. More... | |
int | EventManager::numListeners () |
Get the number of listeners in the dispatch table. More... | |
bool | EventManager::isEventQueueEmpty (EventPriority pri=kLowPriority) |
Check if the event queue is empty. More... | |
bool | EventManager::isEventQueueFull (EventPriority pri=kLowPriority) |
Check if the event queue is full. More... | |
int | EventManager::getNumEventsInQueue (EventPriority pri=kLowPriority) |
Get the number of events in the event queue. More... | |
bool | EventManager::queueEvent (int eventCode, int eventParam, EventPriority pri=kLowPriority) |
Tries to add an event into the event queue. More... | |
int | EventManager::processEvent () |
Processes one event from the event queue and dispatches it to the corresponding listeners stored in the dispatch table. More... | |
int | EventManager::processAllEvents () |
Processes all the events in the event queues and dispatches them to the corresponding listeners stored in the dispatch table. More... | |
This file provides an Event Manager using functional interface under the namespace EventManager.
To use these functions, include EventManager.h and link against EventManager.cpp.
The event queue and and listener list are arrays of fixed size. The size of both can be set at compile time.
The default size of the dispatch table is 8 (event, listener) pairs; you can change the default at compile time by defining the macro EVENTMANAGER_DISPATCH_TABLE_SIZE
prior to including the file EventManager.h, each time it is included. Define it using a compiler option (e.g., -DEVENTMANAGER_DISPATCH_TABLE_SIZE=32
) to ensure it is consistently defined throughout your project.
The default size of the event queues is 8 events (note there are two queues, one for routine priority events), the other for high priority events. You can change the default size of both of the event queues at compile time by defining the macro EVENTMANAGER_EVENT_QUEUE_SIZE
prior to including the file EventManager.h, each time it is included. Define it using a compiler option (e.g., -DEVENTMANAGER_EVENT_QUEUE_SIZE=32
) to ensure it is consistently defined throughout your project.