Empirical
|
#include <EventLib.h>
Classes | |
struct | EventDef |
Event definition structure. Maintains information about a type of event. More... | |
Public Types | |
using | hardware_t = HARDWARE_T |
using | event_t = typename hardware_t::event_t |
using | fun_t = std::function< void(hardware_t &, const event_t &)> |
using | properties_t = std::unordered_set< std::string > |
using | fun_set_t = FunctionSet< void(hardware_t &, const event_t &)> |
Public Member Functions | |
EventLib () | |
EventLib (const EventLib &)=default | |
~EventLib () | |
EventLib & | operator= (const EventLib &)=default |
EventLib & | operator= (EventLib &&)=default |
const std::string & | GetName (size_t id) const |
Get the string name of the specified event definition. More... | |
const fun_t & | GetHandler (size_t id) const |
Get the handler function of the specified event definition. More... | |
const fun_set_t & | GetDispatchFuns (size_t id) const |
Get the dispatch function set of the specified event definition. More... | |
const std::string & | GetDesc (size_t id) const |
Get the string description of the specified event definition. More... | |
const properties_t & | GetProperties (size_t id) const |
Get a const reference to an event definition's properties. More... | |
bool | HasProperty (size_t id, std::string property) const |
Does the event definition specified by id have the property specified. More... | |
size_t | GetSize () const |
Get the number of events registered to this event library. More... | |
size_t | GetID (const std::string &name) const |
Get the event ID of the event given by string name. More... | |
void | AddEvent (const std::string &name, const fun_t &handler_fun, const std::string &desc="", const properties_t &event_properties=properties_t()) |
Add a new event to the event library. More... | |
void | RegisterDispatchFun (size_t id, fun_t dispatch_fun) |
Register a dispatch function for the event specified by id. More... | |
void | RegisterDispatchFun (const std::string &name, fun_t dispatch_fun) |
Register a dispatch function for the event specified by name. More... | |
void | TriggerEvent (hardware_t &hw, const event_t &event) const |
Trigger event. More... | |
void | HandleEvent (hardware_t &hw, const event_t &event) const |
Handle event. More... | |
Protected Attributes | |
emp::vector< EventDef > | event_lib |
std::map< std::string, size_t > | name_map |
using emp::EventLib< HARDWARE_T >::event_t = typename hardware_t::event_t |
using emp::EventLib< HARDWARE_T >::fun_set_t = FunctionSet<void(hardware_t &, const event_t &)> |
using emp::EventLib< HARDWARE_T >::fun_t = std::function<void(hardware_t &, const event_t &)> |
using emp::EventLib< HARDWARE_T >::hardware_t = HARDWARE_T |
using emp::EventLib< HARDWARE_T >::properties_t = std::unordered_set<std::string> |
|
inline |
|
default |
|
inline |
|
inline |
Add a new event to the event library.
|
inline |
Get the string description of the specified event definition.
|
inline |
Get the dispatch function set of the specified event definition.
|
inline |
Get the handler function of the specified event definition.
|
inline |
Get the event ID of the event given by string name.
|
inline |
Get the string name of the specified event definition.
|
inline |
Get a const reference to an event definition's properties.
|
inline |
Get the number of events registered to this event library.
|
inline |
Handle event.
|
inline |
Does the event definition specified by id have the property specified.
|
default |
|
default |
|
inline |
Register a dispatch function for the event specified by id.
|
inline |
Register a dispatch function for the event specified by name.
|
inline |
Trigger event.
|
protected |
|
protected |