Smart< ReferenceCountedObject > Class Template Reference

Smart pointer to reference counted objects. More...

#include <reference-count.h>

Inheritance diagram for Smart< ReferenceCountedObject >:
Inheritance graph
[legend]
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.

Constructor & Destructor Documentation

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

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.

Referenced by Smart< FragmentFileData >::operator=(), and Smart< FragmentFileData >::~Smart().

template<class ReferenceCountedObject>
void Smart< ReferenceCountedObject >::incref (  )  const [inline]
template<class ReferenceCountedObject>
Smart< ReferenceCountedObject >::operator bool (  )  [inline]
template<class ReferenceCountedObject>
template<class AnotherReferenceCountedObject >
Smart< ReferenceCountedObject >::operator Smart< AnotherReferenceCountedObject > (  )  [inline]
template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator!= ( const Smart< ReferenceCountedObject > &  o  )  const [inline]
template<class ReferenceCountedObject>
ReferenceCountedObject& Smart< ReferenceCountedObject >::operator* (  )  [inline]
template<class ReferenceCountedObject>
ReferenceCountedObject* Smart< ReferenceCountedObject >::operator-> (  )  [inline]
template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator< ( const Smart< ReferenceCountedObject > &  o  )  const [inline]
template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator<= ( const Smart< ReferenceCountedObject > &  o  )  const [inline]
template<class ReferenceCountedObject>
template<class AnotherReferenceCountedObject >
Smart<ReferenceCountedObject>& Smart< ReferenceCountedObject >::operator= ( const Smart< AnotherReferenceCountedObject > &  o  )  [inline]
template<class ReferenceCountedObject>
Smart<ReferenceCountedObject>& Smart< ReferenceCountedObject >::operator= ( const Smart< ReferenceCountedObject > &  o  )  [inline]
template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator== ( const Smart< ReferenceCountedObject > &  o  )  const [inline]
template<class ReferenceCountedObject>
bool Smart< ReferenceCountedObject >::operator>= ( const Smart< ReferenceCountedObject > &  o  )  const [inline]

Member Data Documentation

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

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by  doxygen 1.6.2