Empirical
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
emp::EventLib< HARDWARE_T > Class Template Reference

#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 ()
 
EventLiboperator= (const EventLib &)=default
 
EventLiboperator= (EventLib &&)=default
 
const std::string & GetName (size_t id) const
 Get the string name of the specified event definition. More...
 
const fun_tGetHandler (size_t id) const
 Get the handler function of the specified event definition. More...
 
const fun_set_tGetDispatchFuns (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_tGetProperties (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< EventDefevent_lib
 
std::map< std::string, size_t > name_map
 

Member Typedef Documentation

template<typename HARDWARE_T >
using emp::EventLib< HARDWARE_T >::event_t = typename hardware_t::event_t
template<typename HARDWARE_T >
using emp::EventLib< HARDWARE_T >::fun_set_t = FunctionSet<void(hardware_t &, const event_t &)>
template<typename HARDWARE_T >
using emp::EventLib< HARDWARE_T >::fun_t = std::function<void(hardware_t &, const event_t &)>
template<typename HARDWARE_T >
using emp::EventLib< HARDWARE_T >::hardware_t = HARDWARE_T
template<typename HARDWARE_T >
using emp::EventLib< HARDWARE_T >::properties_t = std::unordered_set<std::string>

Constructor & Destructor Documentation

template<typename HARDWARE_T >
emp::EventLib< HARDWARE_T >::EventLib ( )
inline
template<typename HARDWARE_T >
emp::EventLib< HARDWARE_T >::EventLib ( const EventLib< HARDWARE_T > &  )
default
template<typename HARDWARE_T >
emp::EventLib< HARDWARE_T >::~EventLib ( )
inline

Member Function Documentation

template<typename HARDWARE_T >
void emp::EventLib< HARDWARE_T >::AddEvent ( const std::string &  name,
const fun_t handler_fun,
const std::string &  desc = "",
const properties_t event_properties = properties_t() 
)
inline

Add a new event to the event library.

template<typename HARDWARE_T >
const std::string& emp::EventLib< HARDWARE_T >::GetDesc ( size_t  id) const
inline

Get the string description of the specified event definition.

template<typename HARDWARE_T >
const fun_set_t& emp::EventLib< HARDWARE_T >::GetDispatchFuns ( size_t  id) const
inline

Get the dispatch function set of the specified event definition.

template<typename HARDWARE_T >
const fun_t& emp::EventLib< HARDWARE_T >::GetHandler ( size_t  id) const
inline

Get the handler function of the specified event definition.

template<typename HARDWARE_T >
size_t emp::EventLib< HARDWARE_T >::GetID ( const std::string &  name) const
inline

Get the event ID of the event given by string name.

template<typename HARDWARE_T >
const std::string& emp::EventLib< HARDWARE_T >::GetName ( size_t  id) const
inline

Get the string name of the specified event definition.

template<typename HARDWARE_T >
const properties_t& emp::EventLib< HARDWARE_T >::GetProperties ( size_t  id) const
inline

Get a const reference to an event definition's properties.

template<typename HARDWARE_T >
size_t emp::EventLib< HARDWARE_T >::GetSize ( ) const
inline

Get the number of events registered to this event library.

template<typename HARDWARE_T >
void emp::EventLib< HARDWARE_T >::HandleEvent ( hardware_t hw,
const event_t event 
) const
inline

Handle event.

template<typename HARDWARE_T >
bool emp::EventLib< HARDWARE_T >::HasProperty ( size_t  id,
std::string  property 
) const
inline

Does the event definition specified by id have the property specified.

template<typename HARDWARE_T >
EventLib& emp::EventLib< HARDWARE_T >::operator= ( const EventLib< HARDWARE_T > &  )
default
template<typename HARDWARE_T >
EventLib& emp::EventLib< HARDWARE_T >::operator= ( EventLib< HARDWARE_T > &&  )
default
template<typename HARDWARE_T >
void emp::EventLib< HARDWARE_T >::RegisterDispatchFun ( size_t  id,
fun_t  dispatch_fun 
)
inline

Register a dispatch function for the event specified by id.

template<typename HARDWARE_T >
void emp::EventLib< HARDWARE_T >::RegisterDispatchFun ( const std::string &  name,
fun_t  dispatch_fun 
)
inline

Register a dispatch function for the event specified by name.

template<typename HARDWARE_T >
void emp::EventLib< HARDWARE_T >::TriggerEvent ( hardware_t hw,
const event_t event 
) const
inline

Trigger event.

Member Data Documentation

template<typename HARDWARE_T >
emp::vector<EventDef> emp::EventLib< HARDWARE_T >::event_lib
protected
template<typename HARDWARE_T >
std::map<std::string, size_t> emp::EventLib< HARDWARE_T >::name_map
protected

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