8#ifndef META_OCEAN_BASE_EVENT_H
9#define META_OCEAN_BASE_EVENT_H
53 inline unsigned int type()
const;
59 inline unsigned int subtype()
const;
66 template <
typename T>
const T&
cast()
const;
73 template <
typename T> T&
cast();
138 inline void leave()
const;
236 inline unsigned int id()
const;
379 ocean_assert(
dynamic_cast<const T*
>(
this));
380 return dynamic_cast<const T&
>(*this);
386 ocean_assert(
dynamic_cast<const T*
>(
this));
387 return dynamic_cast<T&
>(*this);
This class implements a container for callback functions.
Definition Callback.h:3454
This class implements a vector holding several callbacks with the same type.
Definition Callback.h:3802
This class implements the base class for all event classes.
Definition Event.h:41
Event(const unsigned int type, const unsigned int subtype)
Creates a new event object.
Definition Event.h:359
unsigned int eventSubtype
The sub-type of the event.
Definition Event.h:90
unsigned int subtype() const
Returns the sub-type of this event.
Definition Event.h:371
unsigned int eventType
The type of the event.
Definition Event.h:87
unsigned int type() const
Returns the type of this event.
Definition Event.h:366
virtual ~Event()
Destructs an event object.
const T & cast() const
Casts this event to an event with specified type.
Definition Event.h:377
unsigned int requestId
The registration request id of the new object.
Definition Event.h:256
unsigned int id() const
Returns the registration request id of this object.
Definition Event.h:457
RegistrationRequest(const bool registerCallback, const unsigned int id, const unsigned int eventTypes, const EventCallback &callback)
Creates a new registration request.
Definition Event.h:443
bool requestRegisterCallback
True, to register the callback function; False, to unregister the callback function.
Definition Event.h:253
const EventCallback & callback() const
Returns the callback function of this request object.
Definition Event.h:467
bool registerCallback() const
Returns whether the request intends an register or unregister execution.
Definition Event.h:452
unsigned int eventTypes() const
Returns the event types for which the callback function will be registered or unregistered.
Definition Event.h:462
unsigned int requestEventTypes
The event types for which the callback function will be registered or unregistered.
Definition Event.h:259
EventCallback requestCallback
The callback function of this request.
Definition Event.h:262
Lock managerRegistrationRequestLock
The lock for the registration requests.
Definition Event.h:356
Callback< void, const EventRef & > EventCallback
Definition of a callback function for events.
Definition Event.h:196
void pushEvent(const EventRef &eventObject)
Pushes a new event to the event queue.
~EventManager()
Destructs an event manger object.
RegistrationRequests managerRegistrationRequests
The registration requests which are used to modify the map of callback functions.
Definition Event.h:344
std::map< unsigned int, EventCallbacks > EventCallbacksMap
Definition of a map mapping event types to callback functions.
Definition Event.h:208
EventCallbacksMap managerEventCallbacksMap
The map of callback functions.
Definition Event.h:341
void addEventFunction(const unsigned int eventTypes, const EventCallback &eventCallback)
Adds an event function.
Lock managerLock
The lock for the entire manager.
Definition Event.h:353
std::queue< EventRef > EventQueue
Definition of a queue holding events.
Definition Event.h:273
Callbacks< EventCallback > EventCallbacks
Definition of a set of callback functions.
Definition Event.h:203
EventManager()
Creates a new event manager object.
void removeEventFunction(const unsigned int eventTypes, const EventCallback &eventCallback)
Removes an event function.
EventQueue managerEventQueue
The queue of events waiting to be distributed.
Definition Event.h:338
virtual void threadRun()
The internal thread function.
unsigned int managerRequestCounter
The counter for registration requests.
Definition Event.h:347
void unregisterEventFunction(const unsigned int eventTypes, const EventCallback &eventCallback)
Unregisters a callback function for a specific type or types of events.
std::vector< RegistrationRequest > RegistrationRequests
Definition of a vector holding registration requests.
Definition Event.h:268
IndexSet32 managerRequestSet
The set of pending registration requests.
Definition Event.h:350
void registerEventFunction(const unsigned int eventTypes, const EventCallback &eventCallback)
Registers a callback function for a specific type or types of events.
This class implements a recursive lock object.
Definition Lock.h:31
This template class implements a object reference with an internal reference counter.
Definition base/ObjectRef.h:58
T & scopedBreakEvent
Break event which will be invoked if the leave() function has not been called before this object is d...
Definition Event.h:167
bool scopedEventLeave
Leave statement of this object.
Definition Event.h:176
T & scopedLeaveEvent
Leave event which will be invoked if the leave() function has been called before this object is dispo...
Definition Event.h:170
Callback< void, const T & > EventCallback
Definition of a callback function providing the event as single parameter.
Definition Event.h:111
~ScopedEvent()
Destructs this scoped event object.
Definition Event.h:401
const T & leaveEvent() const
Returns the leave-event of this object, nothing else will be done.
Definition Event.h:432
Callbacks< EventCallback > EventCallbacks
Definition of a list of callback functions.
Definition Event.h:116
void leave() const
Activates the leave event of this object.
Definition Event.h:414
ScopedEvent(const T &enterEvent, T &breakEvent, T &leaveEvent, const EventCallbacks &callbacks)
Creates a new scoped event object.
Definition Event.h:391
const EventCallbacks & scopedCallbacks
A list of callback functions to those the events will be sent.
Definition Event.h:173
const T & breakEvent() const
Returns the break-event of this object, nothing else will be done.
Definition Event.h:420
Thread(const std::string &name=std::string())
Creates a new thread object.
ObjectRef< Event > EventRef
Definition of an object reference holding an event object.
Definition Event.h:30
std::set< Index32 > IndexSet32
Definition of a set holding 32 bit indices.
Definition Base.h:114
The namespace covering the entire Ocean framework.
Definition Accessor.h:15