Graphite
Version 3
An experimental 3D geometry processing program
|
Base class for reference-counted objects. More...
#include <geogram/basic/counted.h>
Public Member Functions | |
void | ref () const |
Increments the reference count. More... | |
void | unref () const |
Decrements the reference count. More... | |
bool | is_shared () const |
Check if the object is shared. More... | |
int | nb_refs () const |
Gets the number of references that point to this object. More... | |
Static Public Member Functions | |
static void | ref (const Counted *counted) |
Increments the reference count. More... | |
static void | unref (const Counted *counted) |
Decrements the reference count. More... | |
Protected Member Functions | |
Counted () | |
Creates a reference counted object. More... | |
virtual | ~Counted () |
Destroys a reference counted object. More... | |
Base class for reference-counted objects.
Reference counted objects implement shared ownership with a simple mechanism: objects willing to share ownership on a Counted object must call ref() on this object and call unref() when they no longer need it. The object is destroyed when no more objects hold a reference on it (when the last holder calls unref()).
Objects can benefit reference counted sharing simply by deriving from Counted and implementing the virtual destructor.
Reference acquisition and release can be done manually by explicitly calling ref() or unref() on the reference counted objects, or can be done automatically by using SmartPointer<T>.
|
inlineprotected |
|
protectedvirtual |
Destroys a reference counted object.
The destructor is never called directly but indirectly through unref(). If the reference counter is not null when the destructor is called the program dies with an assertion failure.
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inlinestatic |