STXXL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::counted_object Class Reference

Detailed Description

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.

+ Inheritance diagram for stxxl::counted_object:
+ Collaboration diagram for stxxl::counted_object:

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_objectoperator= (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...
 

Constructor & Destructor Documentation

stxxl::counted_object::counted_object ( )
inline

new objects have zero reference count

Definition at line 338 of file counting_ptr.h.

stxxl::counted_object::counted_object ( const counted_object )
inline

coping still creates a new object with zero reference count

Definition at line 342 of file counting_ptr.h.

stxxl::counted_object::~counted_object ( )
inline

Definition at line 349 of file counting_ptr.h.

Member Function Documentation

bool stxxl::counted_object::dec_reference ( ) const
inline

Call whenever resetting (i.e. overwriting) a pointer to the object. IMPORTANT: In case of self-assignment, call AFTER inc_reference().

Returns
if the object has to be deleted (i.e. if it's reference count dropped to zero)

Definition at line 360 of file counting_ptr.h.

unsigned_type stxxl::counted_object::get_reference_count ( ) const
inline

Return the number of references to this object (for debugging)

Definition at line 368 of file counting_ptr.h.

void stxxl::counted_object::inc_reference ( ) const
inline

Call whenever setting a pointer to the object.

Definition at line 354 of file counting_ptr.h.

counted_object& stxxl::counted_object::operator= ( const counted_object )
inline

assignment operator, leaves pointers unchanged

Definition at line 346 of file counting_ptr.h.

bool stxxl::counted_object::unique ( ) const
inline

Test if the counted_object is referenced by only one counting_ptr.

Definition at line 364 of file counting_ptr.h.

Member Data Documentation

unsigned_type stxxl::counted_object::m_reference_count
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.


The documentation for this class was generated from the following file: