|
DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
|
Represents the method that will handle an event when the event provides data. More...
#include <EventHandler.h>
Public Member Functions | |
| EventHandler () | |
| Initializes a new empty multicast EventHandler instance. | |
| EventHandler (const EventHandler &other) | |
| Copy constructor. Copies all subscriber callbacks. | |
| EventHandler (EventHandler &&other) noexcept | |
| Move constructor. Transfers subscriber callbacks. | |
| ~EventHandler ()=default | |
| Destructor. | |
| size_t | Add (const Action< const void *, const TEventArgs & > &fnHandler) |
| Subscribes an Action delegate handler and returns a monotonic subscription token. | |
| template<typename F, typename = std::enable_if_t<!std::is_same_v<std::decay_t<F>, EventHandler> && !std::is_same_v<std::decay_t<F>, Action<const void*, const TEventArgs&>> && std::is_invocable_v<std::decay_t<F>, const void*, const TEventArgs&>>> | |
| size_t | Add (F &&fnHandler) |
| Subscribes a generic callable object (lambda or function pointer). | |
| template<typename TClass> | |
| size_t | Add (TClass *pInstance, void(TClass::*pMethod)(const void *, const TEventArgs &)) |
| Subscribes a member method on an instance object. | |
| void | Clear () |
| Removes all registered subscribers. | |
| size_t | GetSubscriberCount () const |
| Gets the number of currently active subscribers. | |
| void | Invoke (const void *pSender, const TEventArgs &e) const |
| Sequentially invokes all registered subscriber callbacks in FIFO order. | |
| bool | IsEmpty () const |
| Checks whether the multicast event handler has zero registered subscribers. | |
| operator bool () const | |
| Boolean conversion operator. Returns true if there are registered subscribers. | |
| void | operator() (const void *pSender, const TEventArgs &e) const |
| Invocation call operator. | |
| size_t | operator+= (const Action< const void *, const TEventArgs & > &fnHandler) |
| Multicast addition operator. Subscribes an Action callback. | |
| EventHandler & | operator+= (const EventHandler &other) |
| Multicast addition operator. Appends all subscribers from another EventHandler. | |
| template<typename F, typename = std::enable_if_t<!std::is_same_v<std::decay_t<F>, EventHandler> && !std::is_same_v<std::decay_t<F>, Action<const void*, const TEventArgs&>> && std::is_invocable_v<std::decay_t<F>, const void*, const TEventArgs&>>> | |
| size_t | operator+= (F &&fnHandler) |
| Multicast addition operator. Subscribes a generic callable object. | |
| bool | operator-= (size_t nToken) |
| Multicast subtraction operator. Unsubscribes using a subscription token. | |
| EventHandler & | operator= (const EventHandler &other) |
| Copy assignment operator. | |
| EventHandler & | operator= (EventHandler &&other) noexcept |
| Move assignment operator. | |
| bool | Remove (size_t nToken) |
| Unsubscribes a subscriber matching the specified subscription token. | |
Represents the method that will handle an event when the event provides data.
| TEventArgs | The type of the event data generated by the event. Defaults to EventArgs. |
Definition at line 27 of file EventHandler.h.
|
inline |
Initializes a new empty multicast EventHandler instance.
Definition at line 47 of file EventHandler.h.
Referenced by EventHandler(), EventHandler(), operator+=(), operator=(), and operator=().
|
inline |
Copy constructor. Copies all subscriber callbacks.
Definition at line 50 of file EventHandler.h.
References EventHandler().
|
inlinenoexcept |
Move constructor. Transfers subscriber callbacks.
Definition at line 54 of file EventHandler.h.
References EventHandler().
|
default |
Destructor.
|
inline |
Subscribes an Action delegate handler and returns a monotonic subscription token.
| fnHandler | The delegate to invoke on event dispatch. |
Assign monotonic unique subscription token.
Append subscriber to registration list.
Definition at line 84 of file EventHandler.h.
Referenced by Add(), Add(), operator+=(), operator+=(), and operator+=().
|
inline |
Subscribes a generic callable object (lambda or function pointer).
Definition at line 95 of file EventHandler.h.
References Add().
|
inline |
Subscribes a member method on an instance object.
Definition at line 101 of file EventHandler.h.
References Add().
|
inline |
Removes all registered subscribers.
Definition at line 149 of file EventHandler.h.
|
inline |
Gets the number of currently active subscribers.
Definition at line 175 of file EventHandler.h.
|
inline |
Sequentially invokes all registered subscriber callbacks in FIFO order.
| pSender | Pointer to the source object initiating the event. |
| e | The event data payload. |
Sequential multicast dispatch to all registered callbacks.
Definition at line 156 of file EventHandler.h.
Referenced by operator()().
|
inline |
Checks whether the multicast event handler has zero registered subscribers.
Definition at line 170 of file EventHandler.h.
Referenced by operator bool().
|
inlineexplicit |
Boolean conversion operator. Returns true if there are registered subscribers.
Definition at line 180 of file EventHandler.h.
References IsEmpty().
|
inline |
|
inline |
Multicast addition operator. Subscribes an Action callback.
Definition at line 110 of file EventHandler.h.
References Add().
|
inline |
Multicast addition operator. Appends all subscribers from another EventHandler.
Definition at line 121 of file EventHandler.h.
References EventHandler(), Add(), and DotNetDupe::System::Collections::Generic::List< T >::GetCount().
|
inline |
Multicast addition operator. Subscribes a generic callable object.
Definition at line 116 of file EventHandler.h.
References Add().
|
inline |
Multicast subtraction operator. Unsubscribes using a subscription token.
Definition at line 144 of file EventHandler.h.
References Remove().
|
inline |
|
inlinenoexcept |
|
inline |
Unsubscribes a subscriber matching the specified subscription token.
| nToken | The subscription token returned from Add. |
Linearly search registry for matching subscription token.
Definition at line 132 of file EventHandler.h.
Referenced by operator-=().