AudRecordLib
|
#include <scoped.h>
Public Member Functions | |
WinType (const Type &data, ReleaseProc lpfnReleaser) | |
WinType (ReleaseProc lpfnReleaser) | |
WinType () | |
~WinType () | |
Type | get () const |
Type | operator* () const |
Type * | operator& () |
operator bool_type () const | |
void | Init (const Type &newData, ReleaseProc lpfnNewReleaser) |
Type | Release () |
void | Swap (WinType &other) |
Wrapper around a Windows resource such as HANDLE
Type | The types of objects that'll be stored and released. Defaults to HANDLE |
Ret | Return type of the function that'll release said resource. Defaults to BOOL |
WinType< Type, Ret >::WinType | ( | const Type & | data, |
ReleaseProc | lpfnReleaser | ||
) | [inline] |
Constructs the object with a resource and a releaser
data | The resource to take ownership of |
lpfnReleaser | The function used to free the resource on destruction |
WinType< Type, Ret >::WinType | ( | ReleaseProc | lpfnReleaser | ) | [inline] |
Constructs an object using the specified resource freeing function
The resource is left uninitialised. This constructor is primarily for use with operator& and passing the uninitialised resource to the creation function as a pointer-pointer parameter. E.g.
create with the releaser function WinType<PBYTE, NET_API_STATUS> memWrap(&NetApiBufferFree); initialise the wrapped resource indirectly NetGroupEnum(NULL, 1, &memWrap, ...);
Constructs an uninitialised object
Init must be called to initialise the object at a later time
Frees the resource if the object has been initialised
Type WinType< Type, Ret >::get | ( | ) | const [inline] |
Retrieves the wrapped resource
The function asserts that the object is initialised before returning the pointer
void WinType< Type, Ret >::Init | ( | const Type & | newData, |
ReleaseProc | lpfnNewReleaser | ||
) | [inline] |
Initialises an uninitialised object
Also asserts that the object hasn't been initialised
newData | A resource that the object takes ownership of. |
lpfnNewReleaser | Function to use to release newData |
WinType< Type, Ret >::operator bool_type | ( | ) | const [inline] |
Safe bool idiom initialised check
Type* WinType< Type, Ret >::operator& | ( | ) | [inline] |
Exposes the address of the wrapped, yet uninitialised resource
This operator is solely intended for use with the function pointer only constructor, whose use is asserted in the function.
Type WinType< Type, Ret >::operator* | ( | ) | const [inline] |
Type WinType< Type, Ret >::Release | ( | ) | [inline] |
Releases the object's ownership of the stored resource
Returns the object back to an uninitialised state. The caller is then responsible for releasing the resource when it is no longer required.
void WinType< Type, Ret >::Swap | ( | WinType< Type, Ret > & | other | ) | [inline] |
Swaps the resources and functions stored in two disperate objects
other | The object to swap this objects internals with |