Native resource guard providing automatic clean up of native pointer types inside managed code.
This is modeled after the C++ standard library autoptr, but intended for use in managed code. When a NativeAutoPointer instance is Reset, Disposed, or cleaned up by the garbage collector, it will destroy its pointer.
A NativeAutoPointer will clean up its pointer using the DestructorPolicy template parameter.
| T | Type of the held pointer. |
| DestructorPolicy | Policy template parameter responsible for cleaning up the pointer. This must be matched to the pointer type's expected destruction method. Defaults to DeletePolicy. |
Public Types |
|
| typedef T | NativeType |
Public Member Functions |
|
| NativeAutoPointer () | |
| Construct an empty NativeAutoPointer.
|
|
| NativeAutoPointer (NativeType *pointer) | |
| Construct a NativeAutoPointer holding the
given pointer. |
|
| ~NativeAutoPointer () | |
| Destructor. |
|
| !NativeAutoPointer () | |
| Finalizer. |
|
| NativeType & | Dereference () |
| Access and dereference the held pointer.
|
|
| NativeType * | Get () |
| Get the held pointer. |
|
| NativeType * | Release () |
| Release the held pointer. |
|
| void | Reset (NativeType *pointer) |
| Clean up the held pointer and take ownership
of a new pointer. |
|
| bool | IsNull () |
| Is the held pointer null? |
|
| typedef T ManagedServices::sealed< T, DestructorPolicy >::NativeType |
| ManagedServices::sealed< T, DestructorPolicy >::~NativeAutoPointer | ( | ) | [inline] |
Destructor.
Destroys the held pointer.
| ManagedServices::sealed< T, DestructorPolicy >::!NativeAutoPointer | ( | ) | [inline] |
Finalizer.
Destroys the held pointer.
| ManagedServices::sealed< T, DestructorPolicy >::NativeAutoPointer | ( | ) | [inline] |
Construct an empty NativeAutoPointer.
| ManagedServices::sealed< T, DestructorPolicy >::NativeAutoPointer | ( | NativeType * | pointer | ) | [inline] |
Construct a NativeAutoPointer holding the given pointer.
| pointer | Pointer to manage |
| NativeType& ManagedServices::sealed< T, DestructorPolicy >::Dereference | ( | ) | [inline] |
Access and dereference the held pointer.
| NativeType* ManagedServices::sealed< T, DestructorPolicy >::Get | ( | ) | [inline] |
Get the held pointer.
This NativeAutoPointer will still own the held pointer.
| NativeType* ManagedServices::sealed< T, DestructorPolicy >::Release | ( | ) | [inline] |
Release the held pointer.
This NativeAutoPointer will no longer be responsible for cleaning up the pointer.
Sets the held pointer to null.
| void ManagedServices::sealed< T, DestructorPolicy >::Reset | ( | NativeType * | pointer | ) | [inline] |
Clean up the held pointer and take ownership of a new pointer.
Cleans up the held pointer using the DestructorPolicy.
<param name="pointer>The new pointer of which this NativeAutoPointer will assume responsibility.
| bool ManagedServices::sealed< T, DestructorPolicy >::IsNull | ( | ) | [inline] |
Is the held pointer null?