Sample implementation for a ManagedPtr. More...
#include <managedptr.h>
Public Types | |
typedef int * | TargetPtrType |
This is type ManagedPtr will use to work with a handle. | |
typedef int | TargetType |
The Type this handle is pointer at. | |
Public Member Functions | |
void | Construct () |
This is expected to leave Pointer in some valid state for dereferencing. | |
void | Deconstruct () |
This can perform any cleanup, but should not fail if Pointer is NULL. More... | |
TargetPtrType | GetPointer () |
This is what the ManagedPtr with use for dereferencing. More... | |
void | SetPointer (TargetPtrType Value) |
This is what ManagedPtr will use in copy and assignment operations as well as invaliding handles. More... | |
Public Attributes | |
TargetPtrType | Pointer |
The ManagedPtr never access objects directly, so this is just an implementation detail. | |
Sample implementation for a ManagedPtr.
This one is pretty useless, and serves as just an example. Any class that implements at least the member function this implements can be used with the ManagedPtr to get smart pointer semantics.
Definition at line 56 of file managedptr.h.
|
inline |
This can perform any cleanup, but should not fail if Pointer is NULL.
Copying or assigning a ManagedPtr just changes which instance of the ManagedPtr will cleanup Ptr. This movement of ownership allows passing or returning ManagedPtr by value or putting it in a standard container. Only the most recent copy will delete the target and none of the earlier copies will. This also stops the target from being deleted multiple times.
Definition at line 77 of file managedptr.h.
|
inline |
This is what the ManagedPtr with use for dereferencing.
Definition at line 86 of file managedptr.h.
|
inline |
This is what ManagedPtr will use in copy and assignment operations as well as invaliding handles.
Value | The new value for the pointer. If NULL the only thing that the ManagedPtr will do to the handle is call its deconstruct method. |
Definition at line 82 of file managedptr.h.