Ref< T > Class Template Reference

This class behaves like a pointer to a refcounted object, but increments the reference count when new objects are assigned and decrements the refcounter when its lifetime has expired. More...

#include <ref.hpp>

List of all members.

Public Member Functions

 Ref (T *object=0)
 Ref (const Ref< T > &other)
 ~Ref ()
Ref< T > & operator= (const Ref< T > &other)
Ref< T > & operator= (T *object)
T * operator-> () const
T & operator * () const
 operator const T * () const
T * get () const

Private Attributes

T * object


Detailed Description

template<typename T>
class Ref< T >

This class behaves like a pointer to a refcounted object, but increments the reference count when new objects are assigned and decrements the refcounter when its lifetime has expired.

(similar to std::auto_ptr)

Definition at line 25 of file ref.hpp.


Constructor & Destructor Documentation

template<typename T>
Ref< T >::Ref ( T *  object = 0  )  [inline]

Definition at line 28 of file ref.hpp.

00029     : object(object)
00030   {
00031     if(object)
00032       object->ref();
00033   }

template<typename T>
Ref< T >::Ref ( const Ref< T > &  other  )  [inline]

Definition at line 34 of file ref.hpp.

00035     : object(other.object)
00036   {
00037     if(object)
00038       object->ref();
00039   }

template<typename T>
Ref< T >::~Ref (  )  [inline]

Definition at line 40 of file ref.hpp.

00041   {
00042     if(object)
00043       object->unref();
00044   }


Member Function Documentation

template<typename T>
Ref<T>& Ref< T >::operator= ( const Ref< T > &  other  )  [inline]

Definition at line 46 of file ref.hpp.

00047   {
00048     *this = other.get();
00049     return *this;
00050   }

template<typename T>
Ref<T>& Ref< T >::operator= ( T *  object  )  [inline]

Definition at line 52 of file ref.hpp.

00053   {
00054     if(object)
00055       object->ref();
00056     if(this->object)
00057       this->object->unref();
00058     this->object = object;
00059 
00060     return *this;
00061   }

template<typename T>
T* Ref< T >::operator-> (  )  const [inline]

Definition at line 63 of file ref.hpp.

00064   {
00065     return object;
00066   }

template<typename T>
T& Ref< T >::operator * (  )  const [inline]

Definition at line 68 of file ref.hpp.

00069   {
00070     return *object;
00071   }

template<typename T>
Ref< T >::operator const T * (  )  const [inline]

Definition at line 73 of file ref.hpp.

References Ref< T >::object.

00074   {
00075     return object;
00076   }

template<typename T>
T* Ref< T >::get (  )  const [inline]

Definition at line 78 of file ref.hpp.

Referenced by Ref< FloatingImage >::operator=().

00079   {
00080     return object;
00081   }


Member Data Documentation

template<typename T>
T* Ref< T >::object [private]

Definition at line 84 of file ref.hpp.

Referenced by Ref< FloatingImage >::get(), Ref< FloatingImage >::operator *(), Ref< T >::operator const T *(), Ref< FloatingImage >::operator->(), Ref< FloatingImage >::Ref(), and Ref< FloatingImage >::~Ref().


The documentation for this class was generated from the following file:
Generated on Mon Jun 9 03:38:34 2014 for SuperTux by  doxygen 1.5.1