Ocean
|
This class implements a subscription object which can be used unique subscriptions to e.g., callback functions. More...
Public Member Functions | |
ScopedSubscriptionT ()=default | |
Creates an invalid (unsubscribed) subscription object. More... | |
ScopedSubscriptionT (ScopedSubscriptionT< T, TOwner > &&scopedSubscription) | |
Move constructor. More... | |
~ScopedSubscriptionT () | |
Destructs the object and releases the subscription if any. More... | |
void | release () |
Explicitly releases the subscription before this object is disposes. More... | |
bool | isValid () const |
Returns whether this object holds a valid subscription. More... | |
operator bool () const | |
Returns whether this object holds a valid subscription. More... | |
ScopedSubscriptionT< T, TOwner > & | operator= (ScopedSubscriptionT< T, TOwner > &&scopedSubscription) |
Move operator. More... | |
bool | operator== (const ScopedSubscriptionT< T, TOwner > &scopedSubscription) const |
Returns whether two subscription objects are identical. More... | |
bool | operator!= (const ScopedSubscriptionT< T, TOwner > &scopedSubscription) const |
Returns whether two subscription objects are not identical. More... | |
size_t | operator() (const ScopedSubscriptionT< T, TOwner > &scopedSubscription) const |
Hash function. More... | |
Protected Types | |
using | ReleaseCallbackFunction = std::function< void(const T &subscriptionId)> |
Definition of a callback function for release requests. More... | |
Protected Member Functions | |
ScopedSubscriptionT (const ScopedSubscriptionT< T, TOwner > &scopedSubscription)=delete | |
Disabled copy constructor. More... | |
ScopedSubscriptionT (const T &subscriptionId, ReleaseCallbackFunction releaseCallbackFunction) | |
Creates a new subscription object for a valid subscription id. More... | |
ScopedSubscriptionT< T, TOwner > & | operator= (const ScopedSubscriptionT< T, TOwner > &scopedSubscription)=delete |
The disabled assign operator. More... | |
Protected Attributes | |
std::unique_ptr< T > | subscriptionId_ = nullptr |
The subscription id, nullptr if invalid. More... | |
ReleaseCallbackFunction | releaseCallbackFunction_ = nullptr |
The callback function which will be used when the subscription needs to be released. More... | |
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 |