Ocean
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > Class Template Reference

This class wraps an unmanaged object (or reference) which needs to be released after usage. More...

Inheritance diagram for Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >:

Public Member Functions

 ScopedObjectCompileTimeT ()=default
 Default constructor creating an object with invalid object. More...
 
 ScopedObjectCompileTimeT (ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &&scopedObject) noexcept
 Move constructor. More...
 
 ScopedObjectCompileTimeT (T &&object) noexcept
 Creates a new scoped object. More...
 
 ScopedObjectCompileTimeT (T &&object, const bool needsRelease) noexcept
 Creates a new scoped object. More...
 
 ScopedObjectCompileTimeT (const T &object)
 Creates a new scoped object. More...
 
 ScopedObjectCompileTimeT (const T &object, const bool needsRelease)
 Creates a new scoped object. More...
 
 ~ScopedObjectCompileTimeT ()
 Destructs this scoped object and releases the internal wrapped object. More...
 
bool isValid () const
 Returns whether this scoped object holds a valid object. More...
 
const T & object () const
 Returns the wrapped object. More...
 
const T & operator-> () const
 Returns the wrapped object. More...
 
const T & operator* () const
 De-reference operator returning the wrapped object. More...
 
T & resetObject (const bool needsRelease=true)
 Releases the current wrapped object and returns a new wrapped object. More...
 
void release ()
 Explicitly releases the wrapped object. More...
 
ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > & operator= (ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &&scopedObject) noexcept
 Move operator. More...
 
 operator const T & () const
 Returns the wrapped object. More...
 

Protected Member Functions

 ScopedObjectCompileTimeT (const ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &)=delete
 Disabled copy constructor. More...
 
ScopedObjectCompileTimeToperator= (const ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &)=delete
 Disabled assign operator. More...
 

Protected Attributes

object_ = tInvalidValue
 The wrapped reference. More...
 
bool needsRelease_ = false
 True, if the wrapped object needs to be released. More...
 

Detailed Description

template<typename T, typename TReleaseValue, typename TReleaseReturn, TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue = NotVoidTyper<TReleaseReturn>::defaultValue(), bool tCheckReturnValue = true, T tInvalidValue = T()>
class Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >

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.

Template Parameters
TThe data type of the wrapped object
TReleaseValueThe optional explicit data type of the object to be released
TReleaseReturnThe data type of the return value of the release function
tReleaseFunctionThe data type of the release function
tExpectedReturnValueThe expected return value of the release function
tCheckReturnValueTrue, to check the return value when calling the release function; False, to ignore the return value
tInvalidValueThe value of an invalid object
See also
ScopedObjectT.

Constructor & Destructor Documentation

◆ ScopedObjectCompileTimeT() [1/7]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue = NotVoidTyper<TReleaseReturn>::defaultValue(), bool tCheckReturnValue = true, T tInvalidValue = T()>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::ScopedObjectCompileTimeT ( )
default

Default constructor creating an object with invalid object.

◆ ScopedObjectCompileTimeT() [2/7]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::ScopedObjectCompileTimeT ( ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &&  scopedObject)
noexcept

Move constructor.

Parameters
scopedObjectThe scoped object to be moved

◆ ScopedObjectCompileTimeT() [3/7]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::ScopedObjectCompileTimeT ( T &&  object)
explicitnoexcept

Creates a new scoped object.

If 'object == tInvalidValue' the object will not be released once this scoped object is disposed.

Parameters
objectThe object to be wrapped

◆ ScopedObjectCompileTimeT() [4/7]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::ScopedObjectCompileTimeT ( T &&  object,
const bool  needsRelease 
)
noexcept

Creates a new scoped object.

Parameters
objectThe object to be wrapped
needsReleaseTrue, 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

◆ ScopedObjectCompileTimeT() [5/7]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::ScopedObjectCompileTimeT ( const T &  object)
explicit

Creates a new scoped object.

If 'object == tInvalidValue' the object will not be released once this scoped object is disposed.

Parameters
objectThe object to be wrapped

◆ ScopedObjectCompileTimeT() [6/7]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::ScopedObjectCompileTimeT ( const T &  object,
const bool  needsRelease 
)

Creates a new scoped object.

Parameters
objectThe object to be wrapped
needsReleaseTrue, 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

◆ ~ScopedObjectCompileTimeT()

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::~ScopedObjectCompileTimeT

Destructs this scoped object and releases the internal wrapped object.

◆ ScopedObjectCompileTimeT() [7/7]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue = NotVoidTyper<TReleaseReturn>::defaultValue(), bool tCheckReturnValue = true, T tInvalidValue = T()>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::ScopedObjectCompileTimeT ( const ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &  )
protecteddelete

Disabled copy constructor.

Member Function Documentation

◆ isValid()

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
bool Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::isValid

Returns whether this scoped object holds a valid object.

Returns
True, if so

◆ object()

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
const T & Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::object

Returns the wrapped object.

Returns
The wrapped object

◆ operator const T &()

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::operator const T &

Returns the wrapped object.

Returns
The wrapped object

◆ operator*()

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
const T & Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::operator*

De-reference operator returning the wrapped object.

Ensure that the object is valid before calling this operator.

Returns
The wrapped object
See also
isValid().

◆ operator->()

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
const T & Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::operator->

Returns the wrapped object.

Ensure that the object is valid before calling this operator.

Returns
The wrapped object
See also
isValid().

◆ operator=() [1/2]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue = NotVoidTyper<TReleaseReturn>::defaultValue(), bool tCheckReturnValue = true, T tInvalidValue = T()>
ScopedObjectCompileTimeT& Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::operator= ( const ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &  )
protecteddelete

Disabled assign operator.

Returns
Reference to this object

◆ operator=() [2/2]

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > & Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::operator= ( ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue > &&  scopedObject)
noexcept

Move operator.

Parameters
scopedObjectThe scoped object to be moved
Returns
Reference to this object

◆ release()

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
void Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::release

Explicitly releases the wrapped object.

◆ resetObject()

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue, bool tCheckReturnValue, T tInvalidValue>
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.

Parameters
needsReleaseTrue, 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
Returns
The new wrapped object

Field Documentation

◆ needsRelease_

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue = NotVoidTyper<TReleaseReturn>::defaultValue(), bool tCheckReturnValue = true, T tInvalidValue = T()>
bool Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::needsRelease_ = false
protected

True, if the wrapped object needs to be released.

◆ object_

template<typename T , typename TReleaseValue , typename TReleaseReturn , TReleaseReturn(*)(TReleaseValue) tReleaseFunction, typename NotVoidTyper< TReleaseReturn >::Type tExpectedReturnValue = NotVoidTyper<TReleaseReturn>::defaultValue(), bool tCheckReturnValue = true, T tInvalidValue = T()>
T Ocean::ScopedObjectCompileTimeT< T, TReleaseValue, TReleaseReturn, tReleaseFunction, tExpectedReturnValue, tCheckReturnValue, tInvalidValue >::object_ = tInvalidValue
protected

The wrapped reference.


The documentation for this class was generated from the following file: