|
Ocean
|
This class wraps an unmanaged object (or reference) which needs to be released after usage. More...
#include <ScopedObject.h>
Public Member Functions | |
| ScopedObjectT ()=default | |
| Default constructor creating an object with invalid object. | |
| ScopedObjectT (ScopedObjectT< T, TReleaseValue, TReleaseFunction > &&scopedObject) noexcept | |
| Move constructor. | |
| ScopedObjectT (T &&object, TReleaseFunction &&releaseFunction) noexcept | |
| Creates a new scoped object. | |
| ScopedObjectT (T &&object, TReleaseFunction &&releaseFunction, const bool useReleaseFunction) noexcept | |
| Creates a new scoped object. | |
| ScopedObjectT (const T &object, TReleaseFunction &&releaseFunction) noexcept | |
| Creates a new scoped object. | |
| ScopedObjectT (const T &object, TReleaseFunction &&releaseFunction, const bool useReleaseFunction) noexcept | |
| Creates a new scoped object. | |
| ~ScopedObjectT () | |
| Destructs this scoped object and releases the internal wrapped object. | |
| bool | isValid () const |
| Returns whether this scoped object holds a valid release function (which will be invoked once the object is released). | |
| const T & | object () const |
| Returns the wrapped object. | |
| const T & | operator-> () const |
| Arrow operator returning the wrapped object. | |
| const T & | operator* () const |
| De-reference operator returning the wrapped object. | |
| void | release () |
| Explicitly releases the wrapped object. | |
| ScopedObjectT< T, TReleaseValue, TReleaseFunction > & | operator= (ScopedObjectT< T, TReleaseValue, TReleaseFunction > &&scopedObject) noexcept |
| Move operator. | |
| operator const T & () const | |
| Returns the wrapped object. | |
Protected Member Functions | |
| ScopedObjectT (const ScopedObjectT< T, TReleaseValue, TReleaseFunction > &)=delete | |
| Disabled copy constructor. | |
| ScopedObjectT< T, TReleaseValue, TReleaseFunction > & | operator= (const ScopedObjectT< T, TReleaseValue, TReleaseFunction > &)=delete |
| Disabled assign operator. | |
Protected Attributes | |
| T | object_ = T() |
| The wrapped reference. | |
| TReleaseFunction | releaseFunction_ = TReleaseFunction() |
| The function used to release the wrapped object. | |
This class wraps an unmanaged object (or reference) which needs to be released after usage.
The release function can be defined at runtime.
| T | The data type of the wrapped object |
| TReleaseValue | The optional explicit data type of the object to be released |
| TReleaseFunction | The data type of the release function |
|
default |
Default constructor creating an object with invalid object.
|
noexcept |
Move constructor.
| scopedObject | The scoped object to be moved |
|
noexcept |
Creates a new scoped object.
| object | The object to be wrapped |
| releaseFunction | The release function |
|
noexcept |
Creates a new scoped object.
This constructor allows to decide at runtime whether the release function will be used or not.
| object | The object to be wrapped |
| releaseFunction | The release function |
| useReleaseFunction | True, to use the provided release function; False, to ignore the provided release function (so that the wrapped object will never be released) |
|
noexcept |
Creates a new scoped object.
| object | The object to be wrapped |
| releaseFunction | The release function |
|
noexcept |
Creates a new scoped object.
This constructor allows to decide at runtime whether the release function will be used or not.
| object | The object to be wrapped |
| releaseFunction | The release function |
| useReleaseFunction | True, to use the provided release function; False, to ignore the provided release function (so that the wrapped object will never be released) |
| Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::~ScopedObjectT | ( | ) |
Destructs this scoped object and releases the internal wrapped object.
|
protecteddelete |
Disabled copy constructor.
| bool Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::isValid | ( | ) | const |
Returns whether this scoped object holds a valid release function (which will be invoked once the object is released).
| const T & Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::object | ( | ) | const |
Returns the wrapped object.
| Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::operator const T & | ( | ) | const |
Returns the wrapped object.
| const T & Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::operator* | ( | ) | const |
De-reference operator returning the wrapped object.
Ensure that the object is valid before calling this operator.
| const T & Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::operator-> | ( | ) | const |
Arrow operator returning the wrapped object.
Ensure that the object is valid before calling this operator.
|
protecteddelete |
Disabled assign operator.
|
noexcept |
Move operator.
| scopedObject | The scoped object to be moved |
| void Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::release | ( | ) |
Explicitly releases the wrapped object.
|
protected |
The wrapped reference.
|
protected |
The function used to release the wrapped object.