3#include <Foundation/Containers/HybridArray.h>
4#include <Foundation/Threading/Lock.h>
5#include <Foundation/Threading/Mutex.h>
6#include <Foundation/Types/Delegate.h>
9using plEventSubscriptionID = plUInt32;
35template <
typename EventData,
typename MutexType, plEventType EventType>
57 m_pEvent = other.m_pEvent;
58 m_SubscriptionID = other.m_SubscriptionID;
67 m_pEvent = other.m_pEvent;
68 m_SubscriptionID = other.m_SubscriptionID;
75 if (m_SubscriptionID == 0)
78 m_pEvent->RemoveEventHandler(m_SubscriptionID);
94 friend class plEventBase<EventData, MutexType, EventType>;
97 plEventSubscriptionID m_SubscriptionID = 0;
150 plUInt8 m_uiRecursionDepth = 0;
151 mutable plEventSubscriptionID m_NextSubscriptionID = 0;
153 mutable MutexType m_Mutex;
155#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT)
156 const void* m_pSelf =
nullptr;
162 plEventSubscriptionID m_SubscriptionID;
175template <
typename EventData,
typename MutexType = plNoMutex,
typename AllocatorWrapper = plDefaultAllocatorWrapper, plEventType EventType = plEventType::Default>
183template <
typename EventData,
typename MutexType = plNoMutex,
typename AllocatorWrapper = plDefaultAllocatorWrapper>
186#include <Foundation/Communication/Implementation/Event_inl.h>
Base class for all memory allocators.
Definition Allocator.h:23
Definition DynamicArray.h:81
An object that can be passed to plEvent::AddEventHandler to store the subscription information and au...
Definition Event.h:50
void Unsubscribe()
If the unsubscriber holds a valid subscription, it will be removed from the target plEvent.
Definition Event.h:73
void Clear()
Resets the unsubscriber. Use when the target plEvent may have been destroyed and automatic unsubscrip...
Definition Event.h:87
bool IsSubscribed() const
Checks whether this unsubscriber has a valid subscription.
Definition Event.h:83
This class propagates event information to registered event handlers.
Definition Event.h:37
@ MaxRecursionDepthDefault
Definition Event.h:109
@ RecursionDepthSupported
Whether the uiMaxRecursionDepth parameter to Broadcast() is supported in this implementation or not.
Definition Event.h:104
bool IsEmpty() const
Returns true, if no event handlers are registered.
Definition Event_inl.h:179
plEventBase(plAllocator *pAllocator)
Constructor.
Definition Event_inl.h:6
bool HasEventHandler(const Handler &handler) const
Checks whether an event handler has already been registered.
Definition Event_inl.h:156
void Clear()
Removes all registered event handlers.
Definition Event_inl.h:172
plEventSubscriptionID AddEventHandler(Handler handler) const
Adds a function as an event handler. All handlers will be notified in the order that they were regist...
Definition Event_inl.h:25
void RemoveEventHandler(const Handler &handler) const
Removes a previously registered handler. It is an error to remove a handler that was not registered.
Definition Event_inl.h:68
void Broadcast(EventData pEventData, plUInt8 uiMaxRecursionDepth=MaxRecursionDepthDefault)
This function will broadcast to all registered users, that this event has just happened....
Definition Event_inl.h:187
Static Conversion Test.
Definition TypeTraits.h:73
Can be used when plEvent is used without any additional data.
Definition Event.h:171