ICAROUS
|
Event Management class. More...
#include <EventManager.hpp>
Public Member Functions | |
void | AddEventHandler (std::string eventName, int priority, std::function< bool(T *)> monitorFunc, std::shared_ptr< EventHandler< T > > eventHandler=nullptr) |
Add a trigger and attach a corresponding event handler. More... | |
void | RunEventMonitors (T *) |
Check all the trigger functions fo active triggers. More... | |
void | RunEventHandlers (T *) |
Execute active handlers. More... | |
void | Run (T *) |
Run event management. | |
void | Reset () |
Reset all triggers and handlers. More... | |
Private Attributes | |
HandlerComp< T > | handlerComp |
List of monitor functions. | |
std::map< std::string, std::function< bool(T *)> > | events |
std::map< std::string, std::shared_ptr< EventHandler< T > > > | handlers |
heapset< std::shared_ptr< EventHandler< T > >, HandlerComp< T > > | activeEventHandlers |
T |
void EventManagement< T >::AddEventHandler | ( | std::string | eventName, |
int | priority, | ||
std::function< bool(T *)> | monitorFunc, | ||
std::shared_ptr< EventHandler< T > > | eventHandler = nullptr |
||
) |
eventName | name of event |
priority | priorit associated with event |
monitorFunc | trigger function |
eventHandler | handler to be fired when trigger is activated |
void EventManagement< T >::Reset |
clear all handlers from priority queue
void EventManagement< T >::RunEventHandlers | ( | T * | state | ) |
If this handler is just starting, make sure the trigger is still true. If trigger is false, remove handler
Elevate priority to ensure this handler continues to execute on the next cycle in case there is another equal priority handler
Upon termination, restore priority
Add any children spawned by the current handler to the queue
void EventManagement< T >::RunEventMonitors | ( | T * | state | ) |
Run the event monitor
If the event is true
Check if the event handler for this event is currently being executed
If the event handler is not part of active handlers, add to active handlers
Get currently executing handler
If the newly added handler takes more priority, stop the previous handler