ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
EventManagement< T > Class Template Reference

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
 

Detailed Description

template<class T>
class EventManagement< T >
Template Parameters
T

Member Function Documentation

◆ AddEventHandler()

template<class T >
void EventManagement< T >::AddEventHandler ( std::string  eventName,
int  priority,
std::function< bool(T *)>  monitorFunc,
std::shared_ptr< EventHandler< T > >  eventHandler = nullptr 
)
Parameters
eventNamename of event
prioritypriorit associated with event
monitorFunctrigger function
eventHandlerhandler to be fired when trigger is activated

◆ Reset()

template<class T >
void EventManagement< T >::Reset

clear all handlers from priority queue

◆ RunEventHandlers()

template<class T >
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

◆ RunEventMonitors()

template<class T >
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


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