The Pedigree Project
0.1
|
#include <SharedPointer.h>
Classes | |
struct | Control |
Public Member Functions | |
SharedPointer () | |
SharedPointer (T *ptr) | |
SharedPointer (SharedPointer< T > &&other) | |
virtual | ~SharedPointer () |
SharedPointer (const SharedPointer< T > &p) | |
void | reset () |
void | reset (T *ptr) |
T * | get () const |
T * | operator-> () const |
T & | operator* () const |
SharedPointer< T > & | operator= (const SharedPointer< T > &p) |
SharedPointer< T > & | operator= (SharedPointer< T > &&p) |
operator bool () const | |
bool | unique () const |
size_t | refcount () const |
bool | operator== (const SharedPointer &p) const |
bool | operator!= (const SharedPointer &p) const |
bool | operator< (const SharedPointer &p) const |
bool | operator<= (const SharedPointer &p) const |
bool | operator> (const SharedPointer &p) const |
bool | operator>= (const SharedPointer &p) const |
Static Public Member Functions | |
template<class... Args> | |
static SharedPointer< T > | allocate (Args...) |
Private Member Functions | |
void | release () |
Private Attributes | |
struct SharedPointer::Control * | m_Control |
Provides a reference-counted pointer that can be freely shared, and is automatically destroyed when the last owner's instance is destructed.
Definition at line 31 of file SharedPointer.h.
SharedPointer< T >::SharedPointer | ( | ) |
Default instantiation, without an associated pointer object.
Definition at line 147 of file SharedPointer.h.
SharedPointer< T >::SharedPointer | ( | T * | ptr | ) |
Instantiate, owning the given memory region.
Definition at line 152 of file SharedPointer.h.
References SharedPointer< T >::reset().
SharedPointer< T >::SharedPointer | ( | SharedPointer< T > && | other | ) |
Move into the given SharedPointer object (no refcount increase). When moving out of a SharedPointer, the previous instance becomes invalid and must be re-initialized.
Definition at line 158 of file SharedPointer.h.
|
virtual |
Destruction, which automatically frees the pointer if no owners remain.
Definition at line 166 of file SharedPointer.h.
References SharedPointer< T >::release().
SharedPointer< T >::SharedPointer | ( | const SharedPointer< T > & | p | ) |
Create another reference to the given SharedPointer.
Definition at line 172 of file SharedPointer.h.
References SharedPointer< T >::release().
|
static |
Creates a SharedPointer with a default allocation.
Definition at line 273 of file SharedPointer.h.
References SharedPointer< T >::reset().
Referenced by Thread::detach(), and SymbolTable::getOrInsertTree().
T * SharedPointer< T >::get | ( | ) | const |
Retrieve the internal pointer, or null if no object is held.
Definition at line 201 of file SharedPointer.h.
Referenced by SharedPointer< T >::operator==().
|
explicit |
Whether or not this pointer is valid.
Definition at line 251 of file SharedPointer.h.
T & SharedPointer< T >::operator* | ( | ) | const |
Dereference the internal pointer (dangerous if no object held).
Definition at line 216 of file SharedPointer.h.
T * SharedPointer< T >::operator-> | ( | ) | const |
Dereference the internal pointer (null if no object is held).
Definition at line 210 of file SharedPointer.h.
SharedPointer< T > & SharedPointer< T >::operator= | ( | const SharedPointer< T > & | p | ) |
Release any currently held object, and then reference that held by the given SharedPointer.
Definition at line 222 of file SharedPointer.h.
References SharedPointer< T >::release().
SharedPointer< T > & SharedPointer< T >::operator= | ( | SharedPointer< T > && | p | ) |
Move the other SharedPointer instance into this one.
Definition at line 241 of file SharedPointer.h.
References SharedPointer< T >::release().
bool SharedPointer< T >::operator== | ( | const SharedPointer< T > & | p | ) | const |
Definition at line 302 of file SharedPointer.h.
References SharedPointer< T >::get().
size_t SharedPointer< T >::refcount | ( | ) | const |
Indicates this SharedPointer's current reference count.
Definition at line 263 of file SharedPointer.h.
Referenced by SharedPointer< T >::unique().
|
private |
Internal do-er to release a reference to the held object.
Definition at line 281 of file SharedPointer.h.
Referenced by SharedPointer< T >::operator=(), SharedPointer< T >::reset(), SharedPointer< T >::SharedPointer(), and SharedPointer< T >::~SharedPointer().
void SharedPointer< T >::reset | ( | ) |
Reset this SharedPointer, reducing the refcount on any held object.
Definition at line 185 of file SharedPointer.h.
References SharedPointer< T >::release().
Referenced by SharedPointer< T >::allocate(), Thread::cleanStateLevel(), and SharedPointer< T >::SharedPointer().
void SharedPointer< T >::reset | ( | T * | ptr | ) |
Reset this SharedPointer, reducing the refcount on any held object, and then set this SharedPointer to track the given memory.
Definition at line 191 of file SharedPointer.h.
References SharedPointer< T >::release().
bool SharedPointer< T >::unique | ( | ) | const |
Indicates whether this SharedPointer is only held by one owner.
Definition at line 257 of file SharedPointer.h.
References SharedPointer< T >::refcount().