|
RAVENNAKIT
|
Super basic list of subscribers. More...
#include <subscriber_list.hpp>
Public Member Functions | |
| SubscriberList ()=default | |
| ~SubscriberList () | |
| SubscriberList (const SubscriberList &)=delete | |
| SubscriberList & | operator= (const SubscriberList &)=delete |
| SubscriberList (SubscriberList &&)=default | |
| SubscriberList & | operator= (SubscriberList &&)=default |
| auto | begin () const |
| auto | end () const |
| auto | begin () |
| auto | end () |
| bool | add (T *subscriber, C context) |
| Adds the given subscriber to the list. | |
| bool | add_or_update_context (T *subscriber, C context) |
| Adds the given subscriber to the list. | |
| bool | update_context (T *subscriber, C context) |
| Updates the context of the given subscriber. | |
| std::optional< C > | remove (const T *subscriber) |
| Removes the given subscriber from the list. | |
| void | clear () |
| Clears the list. | |
| void | foreach (const std::function< void(T *, const C &)> &f, const T *excluding=nullptr) |
| Calls given function for each subscriber. | |
| void | foreach (const std::function< void(T *)> &f, const T *excluding=nullptr) |
| Calls given function for each subscriber. | |
| size_t | size () const |
| bool | empty () const |
| bool | contains (T *subscriber) const |
| Checks if the list contains the given subscriber. | |
Super basic list of subscribers.
Can optionally store a context with each subscriber. This class is not thread save and make sure that the subscriber is not destroyed while it is in the list.
| T | The type of the subscriber. |
| C | The type of the context to store with each subscriber. If void, no context will be stored. |
Definition at line 41 of file subscriber_list.hpp.
|
default |
|
inline |
Definition at line 45 of file subscriber_list.hpp.
|
delete |
|
default |
|
inlinenodiscard |
Adds the given subscriber to the list.
If subscriber is already in the list it will not be added and the context will not be updated. Use add_or_update to update the context.
| subscriber | The subscriber to add. |
| context | The context to add. |
Definition at line 93 of file subscriber_list.hpp.
|
inlinenodiscard |
Adds the given subscriber to the list.
If subscriber is already in the list it will be updated with the new context.
| subscriber | The subscriber to add. |
| context | The context to add. |
Definition at line 109 of file subscriber_list.hpp.
|
inline |
Definition at line 75 of file subscriber_list.hpp.
|
inline |
Definition at line 61 of file subscriber_list.hpp.
|
inline |
Clears the list.
Definition at line 156 of file subscriber_list.hpp.
|
inlinenodiscard |
Checks if the list contains the given subscriber.
| subscriber | The subscriber to check. |
Definition at line 205 of file subscriber_list.hpp.
|
inlinenodiscard |
Definition at line 196 of file subscriber_list.hpp.
|
inline |
Definition at line 82 of file subscriber_list.hpp.
|
inline |
Definition at line 68 of file subscriber_list.hpp.
|
inline |
Calls given function for each subscriber.
| f | The function to call for each subscriber. Must be not null. |
| excluding | The subscriber to exclude from the call. |
Definition at line 178 of file subscriber_list.hpp.
|
inline |
Calls given function for each subscriber.
| f | The function to call for each subscriber. Must be not null. |
| excluding | The subscriber to exclude from the call. |
Definition at line 165 of file subscriber_list.hpp.
|
delete |
|
default |
|
inlinenodiscard |
Removes the given subscriber from the list.
| subscriber | The subscriber to remove. |
Definition at line 142 of file subscriber_list.hpp.
|
inlinenodiscard |
Definition at line 189 of file subscriber_list.hpp.
|
inlinenodiscard |
Updates the context of the given subscriber.
| subscriber | The subscriber to update. |
| context | The new context. |
Definition at line 126 of file subscriber_list.hpp.