tReferencable< T, MUTEX > Class Template Reference

#include <tSafePTR.h>

Inheritance diagram for tReferencable< T, MUTEX >:

Inheritance graph
[legend]
Collaboration diagram for tReferencable< T, MUTEX >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 tReferencable ()
 tReferencable (const tReferencable &)
tReferencableoperator= (const tReferencable &)
void AddRef () const
void Release () const
int GetRefcount () const

Protected Member Functions

 ~tReferencable ()

Private Attributes

int refCtr_
MUTEX mutex_

Friends

class tStackObject< T >


Detailed Description

template<class T, class MUTEX = tNonMutex>
class tReferencable< T, MUTEX >

Definition at line 431 of file tSafePTR.h.


Constructor & Destructor Documentation

template<class T, class MUTEX = tNonMutex>
tReferencable< T, MUTEX >::tReferencable (  )  [inline]

Definition at line 436 of file tSafePTR.h.

00436 :refCtr_(0) {};

template<class T, class MUTEX = tNonMutex>
tReferencable< T, MUTEX >::tReferencable ( const tReferencable< T, MUTEX > &   )  [inline]

Definition at line 437 of file tSafePTR.h.

00437 :refCtr_(0) {};

template<class T, class MUTEX = tNonMutex>
tReferencable< T, MUTEX >::~tReferencable (  )  [inline, protected]

Definition at line 476 of file tSafePTR.h.

00477     {
00478         tASSERT( this && ( refCtr_ == -1000 || refCtr_ == 0 ) );
00479         refCtr_ = -1000;
00480     }


Member Function Documentation

template<class T, class MUTEX = tNonMutex>
tReferencable& tReferencable< T, MUTEX >::operator= ( const tReferencable< T, MUTEX > &   )  [inline]

Definition at line 438 of file tSafePTR.h.

00438 { return *this; }

template<class T, class MUTEX = tNonMutex>
void tReferencable< T, MUTEX >::AddRef ( void   )  const [inline]

Definition at line 440 of file tSafePTR.h.

Referenced by eReferencableGameObject::AddRef().

00441     {
00442 #ifdef DEBUG
00443         st_AddRefBreakpint( this );
00444 #endif        
00445         tASSERT( this && refCtr_ >= 0 );
00446         mutex_.acquire();
00447         ++refCtr_;
00448         mutex_.release();
00449         tASSERT( this && refCtr_ >= 0 );
00450     }

Here is the caller graph for this function:

template<class T, class MUTEX = tNonMutex>
void tReferencable< T, MUTEX >::Release (  )  const [inline]

Definition at line 452 of file tSafePTR.h.

Referenced by eReferencableGameObject::Release().

00453     {
00454 #ifdef DEBUG
00455         st_ReleaseBreakpint( this );
00456 #endif        
00457 
00458         tASSERT ( this && refCtr_ >= 0 );
00459         mutex_.acquire();
00460         --refCtr_;
00461         mutex_.release();
00462 
00463         if ( refCtr_ <= 0 )
00464         {
00465             refCtr_ = -1000;
00466             delete static_cast< const T* >( this );
00467         }
00468     }

Here is the caller graph for this function:

template<class T, class MUTEX = tNonMutex>
int tReferencable< T, MUTEX >::GetRefcount (  )  const [inline]

Definition at line 470 of file tSafePTR.h.

Referenced by eGrid::display_simple().

00471     {
00472         tASSERT( this );
00473         return refCtr_;
00474     }

Here is the caller graph for this function:


Friends And Related Function Documentation

template<class T, class MUTEX = tNonMutex>
friend class tStackObject< T > [friend]

Definition at line 433 of file tSafePTR.h.


Member Data Documentation

template<class T, class MUTEX = tNonMutex>
int tReferencable< T, MUTEX >::refCtr_ [mutable, private]

Definition at line 482 of file tSafePTR.h.

Referenced by tReferencable< eWall >::AddRef(), tReferencable< eWall >::GetRefcount(), tReferencable< eWall >::Release(), and tReferencable< eWall >::~tReferencable().

template<class T, class MUTEX = tNonMutex>
MUTEX tReferencable< T, MUTEX >::mutex_ [mutable, private]

Definition at line 483 of file tSafePTR.h.

Referenced by tReferencable< eWall >::AddRef(), and tReferencable< eWall >::Release().


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:58:57 2008 for Armagetron Advanced by  doxygen 1.5.4