Smart< ReferenceCountedObject > Class Template Reference

Smart pointer to reference counted objects. More...

#include <reference-count.h>

Collaboration diagram for Smart< ReferenceCountedObject >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void incref () const
void decref () const
 Smart (ReferenceCountedObject *p=0)
 Smart (const Smart< ReferenceCountedObject > &o)
Smart< ReferenceCountedObject > & operator= (const Smart< ReferenceCountedObject > &o)
template<class AnotherReferenceCountedObject >
Smart< ReferenceCountedObject > & operator= (const Smart< AnotherReferenceCountedObject > &o)
bool operator== (const Smart< ReferenceCountedObject > &o) const
bool operator!= (const Smart< ReferenceCountedObject > &o) const
bool operator< (const Smart< ReferenceCountedObject > &o) const
bool operator<= (const Smart< ReferenceCountedObject > &o) const
bool operator>= (const Smart< ReferenceCountedObject > &o) const
 ~Smart ()
ReferenceCountedObject & operator* ()
ReferenceCountedObject * operator-> ()
 operator bool ()
template<class AnotherReferenceCountedObject >
 operator Smart< AnotherReferenceCountedObject > ()

Public Attributes

ReferenceCountedObject * ptr


Detailed Description

template<class ReferenceCountedObject>
class Smart< ReferenceCountedObject >

Smart pointer to reference counted objects.

Todo:
actually check whether we cannot create a concurrency problem.

Definition at line 89 of file reference-count.h.


Constructor & Destructor Documentation

template<class ReferenceCountedObject>
Smart< ReferenceCountedObject >::Smart ( ReferenceCountedObject *  p = 0  )  [inline, explicit]

Definition at line 120 of file reference-count.h.

template<class ReferenceCountedObject>
Smart< ReferenceCountedObject >::Smart ( const Smart< ReferenceCountedObject > &  o  )  [inline]

Definition at line 124 of file reference-count.h.

template<class ReferenceCountedObject>
Smart< ReferenceCountedObject >::~Smart (  )  [inline]

Definition at line 164 of file reference-count.h.


Member Function Documentation

template<class ReferenceCountedObject>
void Smart< ReferenceCountedObject >::decref (  )  const [inline]

The general idea is to decrease the reference count of the underlying object in an atomic manner. If the object reaches zero we delete it. With the deletion there are some tricky semantics involved. For instance, if the object that is deleted suddenly passes itself to another one then the reference count will be increased again. However, the object was just being deleted, which means that it should not be deleted again. There are two possible strategies to use this file. Either you do care about using an object that is being deleted (leave everything as it is, the program will crash when you do so). Or you don't care about it and really only want one deletion. In that case, uncomment the assert in the incref method. In both cases, we detect a deletion operation by decreffing the pointer once more.

Definition at line 111 of file reference-count.h.

Here is the caller graph for this function:

template<class ReferenceCountedObject>
void Smart< ReferenceCountedObject >::incref (  )  const [inline]

Definition at line 93 of file reference-count.h.

Here is the caller graph for this function:

template<class ReferenceCountedObject>
Smart< ReferenceCountedObject >::operator bool (  )  [inline]

Definition at line 176 of file reference-count.h.

template<class ReferenceCountedObject>
template<class AnotherReferenceCountedObject >
Smart< ReferenceCountedObject >::operator Smart< AnotherReferenceCountedObject > (  )  [inline]

Definition at line 181 of file reference-count.h.

template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator!= ( const Smart< ReferenceCountedObject > &  o  )  const [inline]

Definition at line 148 of file reference-count.h.

template<class ReferenceCountedObject>
ReferenceCountedObject& Smart< ReferenceCountedObject >::operator* (  )  [inline]

Definition at line 168 of file reference-count.h.

template<class ReferenceCountedObject>
ReferenceCountedObject* Smart< ReferenceCountedObject >::operator-> (  )  [inline]

Definition at line 172 of file reference-count.h.

template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator< ( const Smart< ReferenceCountedObject > &  o  )  const [inline]

Definition at line 152 of file reference-count.h.

template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator<= ( const Smart< ReferenceCountedObject > &  o  )  const [inline]

Definition at line 156 of file reference-count.h.

template<class ReferenceCountedObject>
template<class AnotherReferenceCountedObject >
Smart<ReferenceCountedObject>& Smart< ReferenceCountedObject >::operator= ( const Smart< AnotherReferenceCountedObject > &  o  )  [inline]

Definition at line 136 of file reference-count.h.

template<class ReferenceCountedObject>
Smart<ReferenceCountedObject>& Smart< ReferenceCountedObject >::operator= ( const Smart< ReferenceCountedObject > &  o  )  [inline]

Definition at line 128 of file reference-count.h.

template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator== ( const Smart< ReferenceCountedObject > &  o  )  const [inline]

Definition at line 144 of file reference-count.h.

template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator>= ( const Smart< ReferenceCountedObject > &  o  )  const [inline]

Definition at line 160 of file reference-count.h.


Member Data Documentation

template<class ReferenceCountedObject>
ReferenceCountedObject* Smart< ReferenceCountedObject >::ptr

Definition at line 92 of file reference-count.h.


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

Generated on Sat Feb 20 19:04:27 2010 for Data Objects by  doxygen 1.5.9