STXXL
1.4.0
|
Provides reference counting abilities for use with counting_ptr.
Use as superclass of the actual object, this adds a reference_count value. Then either use counting_ptr as pointer to manage references and deletion, or just do normal new and delete.
For thread-safe functions, use atomic_counted_object instead of this class!
Definition at line 327 of file counting_ptr.h.
Public Member Functions | |
counted_object () | |
new objects have zero reference count More... | |
counted_object (const counted_object &) | |
coping still creates a new object with zero reference count More... | |
~counted_object () | |
bool | dec_reference () const |
Call whenever resetting (i.e. overwriting) a pointer to the object. IMPORTANT: In case of self-assignment, call AFTER inc_reference(). More... | |
unsigned_type | get_reference_count () const |
Return the number of references to this object (for debugging) More... | |
void | inc_reference () const |
Call whenever setting a pointer to the object. More... | |
counted_object & | operator= (const counted_object &) |
assignment operator, leaves pointers unchanged More... | |
bool | unique () const |
Test if the counted_object is referenced by only one counting_ptr. More... | |
Private Attributes | |
unsigned_type | m_reference_count |
the reference count is kept mutable to all const_counting_ptr() to change the reference count. More... | |
|
inline |
new objects have zero reference count
Definition at line 336 of file counting_ptr.h.
|
inline |
coping still creates a new object with zero reference count
Definition at line 340 of file counting_ptr.h.
|
inline |
Definition at line 347 of file counting_ptr.h.
|
inline |
Call whenever resetting (i.e. overwriting) a pointer to the object. IMPORTANT: In case of self-assignment, call AFTER inc_reference().
Definition at line 358 of file counting_ptr.h.
|
inline |
Return the number of references to this object (for debugging)
Definition at line 366 of file counting_ptr.h.
|
inline |
Call whenever setting a pointer to the object.
Definition at line 352 of file counting_ptr.h.
|
inline |
assignment operator, leaves pointers unchanged
Definition at line 344 of file counting_ptr.h.
|
inline |
Test if the counted_object is referenced by only one counting_ptr.
Definition at line 362 of file counting_ptr.h.
|
mutableprivate |
the reference count is kept mutable to all const_counting_ptr() to change the reference count.
Definition at line 332 of file counting_ptr.h.