A reference counting pointer that revokes (NULLs) all copies when one set to AutoRevoke(true) leaves scope. More...
#include <RevPtr.h>
Public Member Functions | |
RevPtr (T *t_ptr=NULL) | |
Default constructor assigning the value of the pointer. More... | |
RevPtr (const RevPtr< T > &other) | |
Copy constructor. More... | |
RevPtr (const Ptr< T > &other) | |
A conversion constructor which creates a new RevPtr from a Ptr of the same or a derived type. More... | |
RevPtr (const APtr< T > &other) | |
A conversion constructor which creates a new RevPtr from an APtr of the same or a derived type. More... | |
RevPtr & | operator= (const RevPtr< T > &other) |
An assignment operator which joins this RevPtr to the other RevPtr. More... | |
~RevPtr () | |
Destructor which revokes the pointer only if AutoRevoke() was used on this object. | |
void | Delete () |
Manually delete the object pointed to by this RevPtr, and revoke the pointer for all shared RevPtr's. More... | |
void | Revoke () |
Manually revoke the pointer, setting it equal to NULL for all shared RevPtr objects. More... | |
void | AutoRevoke (bool new_auto_revoke=true) |
Set this RevPtr to revoke the pointer upon deletion or leaving scope. More... | |
A reference counting pointer that revokes (NULLs) all copies when one set to AutoRevoke(true) leaves scope.
This pointer class does not automatically delete the object pointed to, so that it can be used for self-referential purposes. For automatic deletion, use an APtr, and create a RevPtr family that refers to the Ptr of the same scope. Like Ptr and APtr, dereferencing a null RevPtr throws ErrorMsgNull. Note: Revocation is thread safe, but a previously extracted raw ptr could remain in use after revocation. Be mindful of this in threading architecture design.
|
inline |
Default constructor assigning the value of the pointer.
t_ptr | The new pointer value. |
|
inline |
Copy constructor.
other | The RevPtr to copy. |
|
inline |
|
inline |
|
inline |
Set this RevPtr to revoke the pointer upon deletion or leaving scope.
new_auto_revoke | True if this RevPtr should automatically revoke. The recommended way to use this feature is to place the primary RevPtr in scope with the object to which it points so that they are deleted together, and then call AutoRevoke() on that RevPtr. Then all other RevPtr's which have been assigned or copy constructed from the primary RevPtr will be automatically revoked when it is destructed, and they will all return true for IsNull or throw exceptions if dereferencing is attempted. |
|
inline |
Manually delete the object pointed to by this RevPtr, and revoke the pointer for all shared RevPtr's.
Note: While this NULLs all the linked RevPtr's, it cannot affect raw pointers which have already been extracted or are in use when this is called. Be mindful of this in threading architecture design.
|
inline |
|
inline |
Manually revoke the pointer, setting it equal to NULL for all shared RevPtr objects.
This does not delete the pointer.