Ocean
|
This class wraps an unmanaged object (or reference) which needs to be released after usage. More...
Public Member Functions | |
ScopedObjectT ()=default | |
Default constructor creating an object with invalid object. More... | |
ScopedObjectT (ScopedObjectT< T, TReleaseValue, TReleaseFunction > &&scopedObject) noexcept | |
Move constructor. More... | |
ScopedObjectT (T &&object, TReleaseFunction &&releaseFunction) noexcept | |
Creates a new scoped object. More... | |
ScopedObjectT (T &&object, TReleaseFunction &&releaseFunction, const bool useReleaseFunction) noexcept | |
Creates a new scoped object. More... | |
ScopedObjectT (const T &object, TReleaseFunction &&releaseFunction) noexcept | |
Creates a new scoped object. More... | |
ScopedObjectT (const T &object, TReleaseFunction &&releaseFunction, const bool useReleaseFunction) noexcept | |
Creates a new scoped object. More... | |
~ScopedObjectT () | |
Destructs this scoped object and releases the internal wrapped object. More... | |
bool | isValid () const |
Returns whether this scoped object holds a valid release function (which will be invoked once the object is released). More... | |
const T & | object () const |
Returns the wrapped object. More... | |
const T & | operator-> () const |
Arrow operator returning the wrapped object. More... | |
const T & | operator* () const |
De-reference operator returning the wrapped object. More... | |
void | release () |
Explicitly releases the wrapped object. More... | |
ScopedObjectT< T, TReleaseValue, TReleaseFunction > & | operator= (ScopedObjectT< T, TReleaseValue, TReleaseFunction > &&scopedObject) noexcept |
Move operator. More... | |
operator const T & () const | |
Returns the wrapped object. More... | |
Protected Member Functions | |
ScopedObjectT (const ScopedObjectT< T, TReleaseValue, TReleaseFunction > &)=delete | |
Disabled copy constructor. More... | |
ScopedObjectT< T, TReleaseValue, TReleaseFunction > & | operator= (const ScopedObjectT< T, TReleaseValue, TReleaseFunction > &)=delete |
Disabled assign operator. More... | |
Protected Attributes | |
T | object_ = T() |
The wrapped reference. More... | |
TReleaseFunction | releaseFunction_ = TReleaseFunction() |
The function used to release the wrapped object. More... | |
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 |
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 |
Returns the wrapped object.
Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::operator const T & |
Returns the wrapped object.
const T & Ocean::ScopedObjectT< T, TReleaseValue, TReleaseFunction >::operator* |
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-> |
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.