|
Ocean
|
This class implements a subscription object which can be used unique subscriptions to e.g., callback functions. More...
#include <ScopedSubscription.h>
Public Member Functions | |
| ScopedSubscriptionT ()=default | |
| Creates an invalid (unsubscribed) subscription object. | |
| ScopedSubscriptionT (ScopedSubscriptionT< T, TOwner > &&scopedSubscription) | |
| Move constructor. | |
| ~ScopedSubscriptionT () | |
| Destructs the object and releases the subscription if any. | |
| void | release () |
| Explicitly releases the subscription before this object is disposes. | |
| bool | isValid () const |
| Returns whether this object holds a valid subscription. | |
| operator bool () const | |
| Returns whether this object holds a valid subscription. | |
| ScopedSubscriptionT< T, TOwner > & | operator= (ScopedSubscriptionT< T, TOwner > &&scopedSubscription) |
| Move operator. | |
| bool | operator== (const ScopedSubscriptionT< T, TOwner > &scopedSubscription) const |
| Returns whether two subscription objects are identical. | |
| bool | operator!= (const ScopedSubscriptionT< T, TOwner > &scopedSubscription) const |
| Returns whether two subscription objects are not identical. | |
| size_t | operator() (const ScopedSubscriptionT< T, TOwner > &scopedSubscription) const |
| Hash function. | |
Protected Types | |
| using | ReleaseCallbackFunction = std::function< void(const T &subscriptionId)> |
| Definition of a callback function for release requests. | |
Protected Member Functions | |
| ScopedSubscriptionT (const ScopedSubscriptionT< T, TOwner > &scopedSubscription)=delete | |
| Disabled copy constructor. | |
| ScopedSubscriptionT (const T &subscriptionId, ReleaseCallbackFunction releaseCallbackFunction) | |
| Creates a new subscription object for a valid subscription id. | |
| ScopedSubscriptionT< T, TOwner > & | operator= (const ScopedSubscriptionT< T, TOwner > &scopedSubscription)=delete |
| The disabled assign operator. | |
Protected Attributes | |
| std::unique_ptr< T > | subscriptionId_ = nullptr |
| The subscription id, nullptr if invalid. | |
| ReleaseCallbackFunction | releaseCallbackFunction_ = nullptr |
| The callback function which will be used when the subscription needs to be released. | |
Private Attributes | |
| friend | TOwner |
This class implements a subscription object which can be used unique subscriptions to e.g., callback functions.
The subscription exists as long as the object exists.
| T | The data type of the subscription id |
| TOwner | The data type of the class in which this subscription object will be defined |
|
protected |
Definition of a callback function for release requests.
| subscriptionId | The id of the subscription to be released |
|
default |
Creates an invalid (unsubscribed) subscription object.
|
inline |
Move constructor.
| scopedSubscription | The object to be moved |
| Ocean::ScopedSubscriptionT< T, TOwner >::~ScopedSubscriptionT | ( | ) |
Destructs the object and releases the subscription if any.
|
protecteddelete |
Disabled copy constructor.
| scopedSubscription | The object which would be copied |
|
inlineexplicitprotected |
Creates a new subscription object for a valid subscription id.
| subscriptionId | The subscription id, must be valid |
| releaseCallbackFunction | The callback function which will be used when the subscription needs to be released, must be valid |
|
inline |
Returns whether this object holds a valid subscription.
|
inlineexplicit |
Returns whether this object holds a valid subscription.
|
inline |
Returns whether two subscription objects are not identical.
| scopedSubscription | The second subscription object to compare |
|
inline |
Hash function.
| scopedSubscription | The object for which the hash value will be determined |
|
protecteddelete |
The disabled assign operator.
| scopedSubscription | The object which would be assigned |
|
inline |
Move operator.
| scopedSubscription | The object to be moved |
|
inline |
Returns whether two subscription objects are identical.
| scopedSubscription | The second subscription object to compare |
| void Ocean::ScopedSubscriptionT< T, TOwner >::release | ( | ) |
Explicitly releases the subscription before this object is disposes.
|
protected |
The callback function which will be used when the subscription needs to be released.
|
protected |
The subscription id, nullptr if invalid.
|
private |