|
Ocean
|
This class wraps an unmanaged object (or reference) which needs to be released after usage. More...
#include <ScopedObject.h>
Public Member Functions | |
| ScopedObjectCompileTimeT ()=default | |
| Default constructor creating an object with invalid object. | |
| ScopedObjectCompileTimeT (ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &&scopedObject) noexcept | |
| Move constructor. | |
| ScopedObjectCompileTimeT (T &&object) noexcept | |
| Creates a new scoped object. | |
| ScopedObjectCompileTimeT (T &&object, const bool needsRelease) noexcept | |
| Creates a new scoped object. | |
| ScopedObjectCompileTimeT (const T &object) | |
| Creates a new scoped object. | |
| ScopedObjectCompileTimeT (const T &object, const bool needsRelease) | |
| Creates a new scoped object. | |
| ~ScopedObjectCompileTimeT () | |
| Destructs this scoped object and releases the internal wrapped object. | |
| bool | isValid () const |
| Returns whether this scoped object holds a valid object. | |
| const T & | object () const |
| Returns the wrapped object. | |
| const T & | operator-> () const |
| Returns the wrapped object. | |
| const T & | operator* () const |
| De-reference operator returning the wrapped object. | |
| T & | resetObject (const bool needsRelease=true) |
| Releases the current wrapped object and returns a new wrapped object. | |
| void | release () |
| Explicitly releases the wrapped object. | |
| ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > & | operator= (ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &&scopedObject) noexcept |
| Move operator. | |
| operator const T & () const | |
| Returns the wrapped object. | |
Protected Member Functions | |
| ScopedObjectCompileTimeT (const ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &)=delete | |
| Disabled copy constructor. | |
| ScopedObjectCompileTimeT & | operator= (const ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &)=delete |
| Disabled assign operator. | |
Protected Attributes | |
| T | object_ = tInvalidValue |
| The wrapped reference. | |
| bool | needsRelease_ = false |
| True, if the wrapped object needs to be released. | |
This class wraps an unmanaged object (or reference) which needs to be released after usage.
The release function needs to be defined at compile time.
| T | The data type of the wrapped object |
| TReleaseValue | The optional explicit data type of the object to be released |
| TReleaseReturn | The data type of the return value of the release function |
| tReleaseFunction | The data type of the release function |
| tExpectedReturnValue | The expected return value of the release function |
| tCheckReturnValue | True, to check the return value when calling the release function; False, to ignore the return value |
| tInvalidValue | The value of an invalid object |
|
default |
Default constructor creating an object with invalid object.
|
noexcept |
Move constructor.
| scopedObject | The scoped object to be moved |
|
explicitnoexcept |
Creates a new scoped object.
If 'object == tInvalidValue' the object will not be released once this scoped object is disposed.
| object | The object to be wrapped |
|
noexcept |
Creates a new scoped object.
| object | The object to be wrapped |
| needsRelease | True, if the given object needs to be released once the scoped object is disposed; False, if the given object does not need to be released |
|
explicit |
Creates a new scoped object.
If 'object == tInvalidValue' the object will not be released once this scoped object is disposed.
| object | The object to be wrapped |
| Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::ScopedObjectCompileTimeT | ( | const T & | object, |
| const bool | needsRelease | ||
| ) |
Creates a new scoped object.
| object | The object to be wrapped |
| needsRelease | True, if the given object needs to be released once the scoped object is disposed; False, if the given object does not need to be released |
| Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::~ScopedObjectCompileTimeT | ( | ) |
Destructs this scoped object and releases the internal wrapped object.
|
protecteddelete |
Disabled copy constructor.
| bool Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::isValid | ( | ) | const |
Returns whether this scoped object holds a valid object.
| const T & Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::object | ( | ) | const |
Returns the wrapped object.
| Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::operator const T & | ( | ) | const |
Returns the wrapped object.
| const T & Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::operator* | ( | ) | const |
De-reference operator returning the wrapped object.
Ensure that the object is valid before calling this operator.
| const T & Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::operator-> | ( | ) | const |
Returns 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::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::release | ( | ) |
Explicitly releases the wrapped object.
| T & Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::resetObject | ( | const bool | needsRelease = true | ) |
Releases the current wrapped object and returns a new wrapped object.
| needsRelease | True, if the new object needs to be released once the scoped object is disposed; False, if the new object does not need to be released |
|
protected |
True, if the wrapped object needs to be released.
|
protected |
The wrapped reference.