CXXR (C++ R)
|
Smart pointer to protect a GCNode from garbage collection. More...
#include <GCRoot.h>
Public Member Functions | |
GCRoot (T *node=0) | |
GCRoot (const GCRoot &source) | |
Copy constructor. | |
GCRoot & | operator= (const GCRoot &source) |
GCRoot & | operator= (T *node) |
T * | operator-> () const |
Access member via encapsulated pointer. | |
T & | operator* () const |
Dereference the encapsulated pointer. | |
operator T * () const | |
Implicit conversion to encapsulated pointer type. | |
T * | get () const |
Access the encapsulated pointer. |
Additional Inherited Members | |
Static Public Member Functions inherited from CXXR::GCRootBase | |
static void | visitRoots (GCNode::const_visitor *v) |
Conduct a const visitor to all 'root' GCNode objects. | |
Protected Member Functions inherited from CXXR::GCRootBase | |
GCRootBase (const GCNode *node) | |
Primary constructor. | |
GCRootBase (const GCRootBase &source) | |
Copy constructor. | |
GCRootBase & | operator= (const GCRootBase &source) |
void | redirect (const GCNode *node) |
Change the node protected by this GCRootBase. | |
const GCNode * | ptr () const |
Access the encapsulated pointer. |
Smart pointer to protect a GCNode from garbage collection.
This class encapsulates a pointer to an object of a type derived from GCNode. For as long as the GCRoot object exists, the GCNode that it points to will not be garbage collected.
This class performs a similar function to GCStackRoot, but is intended for variables that are not allocated on the stack. Unlike GCStackRoot objects, there is no requirement that GCRoot objects be destroyed in the reverse order of their creation; the price of this is that there is a slightly greater time overhead to construction and destruction.
It is not recommended to declare a GCRoot (or indeed any object requiring non-trivial construction) at file or namespace scope in circumstances where the order of initialisation of data in different source files may be an issue. See the way in which Environment::s_base
is declared and initialised in Environment.cpp for a preferable approach.
|
inlineexplicit |
node | Pointer the node to be pointed to, and protected from the garbage collector, or a null pointer. |
|
inline |
|
inline |
Access the encapsulated pointer.
|
inline |
Implicit conversion to encapsulated pointer type.
|
inline |
Dereference the encapsulated pointer.
|
inline |
Access member via encapsulated pointer.
|
inline |
|
inline |