class ref_ptr

Reference Counted Pointer Class. More...

Definition#include <ref_ptr.hh>
Template formref_ptr<class _Tp>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Protected Methods

Protected Members


Detailed Description

The ref_ptr class is a strong reference class. It maintains a count of how many references to an object exist and releases the memory associated with the object when the reference count reaches zero. The reference pointer can be dereferenced like an ordinary pointer to call methods on the reference counted object.

At the time of writing the only supported memory management is through the new and delete operators. At a future date, this class should support the STL allocator classes or an equivalent to provide greater flexibility.

typedef ref_ptr<const _Tp> const_ref_ptr

const_ref_ptr

 ref_ptr (_Tp* __p = 0)

ref_ptr

Construct a reference pointer for object.

Parameters:
ppointer to object to be reference counted. p must be allocated using operator new as it will be destructed using delete when the reference count reaches zero.

 ref_ptr (const ref_ptr& __r)

ref_ptr

Copy Constructor

Constructs a reference pointer for object. Raises reference count associated with object by 1.

ref_ptr&  operator= (const ref_ptr& __r)

operator=

Assignment Operator

Assigns reference pointer to new object.

 ~ref_ptr ()

~ref_ptr

Destruct reference pointer instance and lower reference count on object being tracked. The object being tracked will be deleted if the reference count falls to zero because of the destruction of the reference pointer.

inline _Tp&  operator* ()

operator*

[const]

Dereference reference counted object.

Returns: reference to object.

inline _Tp*  operator-> ()

operator->

[const]

Dereference pointer to refence counted object.

Returns: pointer to object.

inline _Tp*  get ()

get

[const]

Dereference pointer to refence counted object.

Returns: pointer to object.

inline bool  operator== (const ref_ptr& rp)

operator==

[const]

Equality Operator

Returns: true if reference pointers refer to same object.

inline bool  is_empty ()

is_empty

[const]

Check if reference pointer refers to an object or whether it has been assigned a null object.

Returns: true if reference pointer refers to a null object.

inline bool  is_only ()

is_only

[const]

Returns: true if reference pointer represents only reference to object.

bool  at_least (int32_t n)

at_least

[const]

Parameters:
nminimum count.

Returns: true if there are at least n references to object.

inline void  release ()

release

[const]

Release reference on object. The reference pointers underlying object is set to null, and the former object is destructed if necessary.

inline operator  const_ref_ptr ()

const_ref_ptr

 ref_ptr (_Tp* data, int32_t counter)

ref_ptr

inline int32_t  counter ()

counter

[protected const]

void  ref (const ref_ptr* __r)

ref

[protected const]

Add reference.

void  unref ()

unref

[protected const]

Remove reference.

mutable _Tp* _M_ptr

_M_ptr

[protected]

mutable int32_t _M_counter

_M_counter

[protected]


Generated by: pavlin on possum.icir.org on Mon Jun 9 13:23:43 2003, using kdoc 2.0a54+XORP.