STXXL
1.4-dev
|
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 329 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 338 of file counting_ptr.h.
|
inline |
coping still creates a new object with zero reference count
Definition at line 342 of file counting_ptr.h.
|
inline |
Definition at line 349 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 360 of file counting_ptr.h.
|
inline |
Return the number of references to this object (for debugging)
Definition at line 368 of file counting_ptr.h.
|
inline |
Call whenever setting a pointer to the object.
Definition at line 354 of file counting_ptr.h.
|
inline |
assignment operator, leaves pointers unchanged
Definition at line 346 of file counting_ptr.h.
|
inline |
Test if the counted_object is referenced by only one counting_ptr.
Definition at line 364 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 334 of file counting_ptr.h.