MAK Legion 1.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
Legion::EventManager Class Reference

The EventManager manages the creation and distribution of simulation events such as Fire and Detonate. More...

+ Collaboration diagram for Legion::EventManager:

Classes

struct  CallbackData
 

Public Member Functions

template<typename EVENT_TYPE >
EVENT_TYPE createEvent ()
 Create an event of a given type for sending. More...
 
virtual EventManagerHandle handle () const
 Get the handle to the underlying implementation. More...
 
virtual UInt32 addEvent (const EventInstance &iEvent)
 Add a created event to the database for distribution. More...
 
virtual EventId registerEvent (const EventDescriptor &reg)
 Register event type so as to be able to access events (add/peek/get) More...
 
virtual ParameterId parameterId (EventId eventId, const std::string &parameterName)
 Get the generated parameter ID for a given event type. More...
 
template<typename EVENT_TYPE >
UInt32 addEventCallback (Callback< void(Span< EVENT_TYPE > &)> cb)
 Adds a callback function for an interested event type. More...
 
template<typename EVENT_TYPE >
bool removeEventCallback (UInt32 handle)
 Remove a callback using the handle that was returned when it the callback was added. More...
 
template<typename EVENT_TYPE >
const std::vector< const
EVENT_TYPE > 
getEvents ()
 Get events for this frame. More...
 
template<typename EVENT_TYPE >
const std::vector< EVENT_TYPE > peekEvents ()
 Peek events intended for next frame. This may return an incomplete list if other threads are still creating events. More...
 
virtual UInt32 nextId ()
 returns the next available event ID More...
 
virtual bool selfReflecting () const
 
virtual void setSelfReflecting (bool val)
 
virtual void addInterest (const EventId eventId)
 
virtual void removeInterest (const EventId eventId)
 

Protected Member Functions

 EventManager (EventManagerHandle handle)
 Constructor. More...
 
virtual ~EventManager ()
 Destructor. More...
 

Static Protected Member Functions

static void callback (void *usr, EventHandle *events, UInt32 count)
 

Protected Attributes

std::vector< CallbackData * > myCallbackData
 
std::atomic< int > myNextId
 
EventManagerHandle myHandle
 

Friends

class SimulationDatabase
 

Detailed Description

The EventManager manages the creation and distribution of simulation events such as Fire and Detonate.

The event manager is created and owned by the simulation database

Constructor & Destructor Documentation

Legion::EventManager::EventManager ( EventManagerHandle  handle)
protected

Constructor.

virtual Legion::EventManager::~EventManager ( )
protectedvirtual

Destructor.

Member Function Documentation

virtual UInt32 Legion::EventManager::addEvent ( const EventInstance iEvent)
virtual

Add a created event to the database for distribution.

Referenced by DtVehicleSim::detonateMunition(), DtVehicleSim::fireMunition(), and main().

template<typename EVENT_TYPE >
UInt32 Legion::EventManager::addEventCallback ( Callback< void(Span< EVENT_TYPE > &)>  cb)

Adds a callback function for an interested event type.

So it can be notified whenever the type of events are received This returns a handle for the callback, which is used to unregister the callback.

References callback(), Legion::EventManager::CallbackData::convertAndExecute, Legion::EventManager::CallbackData::handle, legion_eventManager_addCallback(), myCallbackData, and myHandle.

Referenced by DtVehicleSim::DtVehicleSim(), and main().

virtual void Legion::EventManager::addInterest ( const EventId  eventId)
virtual
static void Legion::EventManager::callback ( void *  usr,
EventHandle events,
UInt32  count 
)
staticprotected
template<typename EVENT_TYPE >
EVENT_TYPE Legion::EventManager::createEvent ( )

Create an event of a given type for sending.

References handle(), legion_eventManager_createEvent(), and myHandle.

Referenced by DtVehicleSim::detonateMunition(), DtVehicleSim::fireMunition(), and main().

template<typename EVENT_TYPE >
const std::vector< const EVENT_TYPE > Legion::EventManager::getEvents ( )

Get events for this frame.

References legion_eventManager_getEvents(), and myHandle.

virtual EventManagerHandle Legion::EventManager::handle ( ) const
virtual

Get the handle to the underlying implementation.

Referenced by createEvent().

virtual UInt32 Legion::EventManager::nextId ( )
virtual

returns the next available event ID

Referenced by DtVehicleSim::fireMunition().

virtual ParameterId Legion::EventManager::parameterId ( EventId  eventId,
const std::string &  parameterName 
)
virtual

Get the generated parameter ID for a given event type.

Referenced by SosSignalEvent::registerEvent().

template<typename EVENT_TYPE >
const std::vector< EVENT_TYPE > Legion::EventManager::peekEvents ( )

Peek events intended for next frame. This may return an incomplete list if other threads are still creating events.

References legion_eventManager_peekEvents(), and myHandle.

virtual EventId Legion::EventManager::registerEvent ( const EventDescriptor reg)
virtual

Register event type so as to be able to access events (add/peek/get)

Referenced by SosSignalEvent::registerEvent().

template<typename EVENT_TYPE >
bool Legion::EventManager::removeEventCallback ( UInt32  handle)

Remove a callback using the handle that was returned when it the callback was added.

This removes the interest of type of events.

References callback(), legion_eventManager_removeCallback(), myCallbackData, and myHandle.

Referenced by main(), and DtVehicleSim::~DtVehicleSim().

virtual void Legion::EventManager::removeInterest ( const EventId  eventId)
virtual
virtual bool Legion::EventManager::selfReflecting ( ) const
virtual
virtual void Legion::EventManager::setSelfReflecting ( bool  val)
virtual

Friends And Related Function Documentation

friend class SimulationDatabase
friend

Member Data Documentation

std::vector<CallbackData*> Legion::EventManager::myCallbackData
protected
EventManagerHandle Legion::EventManager::myHandle
protected
std::atomic<int> Legion::EventManager::myNextId
protected

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

Document ID: Generated on Wed May 26 15:17:05 EDT 2021 from SVN revision 229676
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)