Ceylan::CountedPointer< T > Class Template Reference

#include <CeylanCountedPointer.h>

Inheritance diagram for Ceylan::CountedPointer< T >:

Inheritance graph
[legend]
Collaboration diagram for Ceylan::CountedPointer< T >:

Collaboration graph
[legend]

List of all members.

Classes

struct  Referent
 Second: implementation. More...

Public Types

typedef T ElementType
 The counted object (wrapped resource) type.
enum  TextOutputFormat { rawText, html }
 Defines what text output formats for TextDisplayable instances are available. More...

Public Member Functions

 CountedPointer (ElementType *resourcePointer=0)
 CountedPointer (const CountedPointer< T > &source)
 Copy constructor.
CountedPointer< T > & operator= (const CountedPointer< T > &source)
 ~CountedPointer () throw ()
 Destructor of a counted pointer, decreases the reference count which may lead to deallocation of resource.
ElementTypeoperator* () const
 Dereferences the counted pointer to access the wrapped resource, and returns a reference to this resource.
ElementTypeoperator-> () const
 Returns the wrapped resource pointer.
ElementTypeget () const
 Returns the wrapped resource pointer.
bool isUnique () const
 Tells whether the reference count for the wrapped resource is exactly 1.
ReferenceCount getReferenceCount () const
 Returns the reference count for this counted pointer.
virtual const std::string toString (VerbosityLevels level=high) const
 Returns a user-friendly description of this counted pointer.

Static Public Member Functions

static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.

Static Protected Attributes

static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.

Private Member Functions

void reset (Referent *refPointer)
 Each CountedPointer has therefore a member: Referent * _referent ;.
void setReferent (Referent *refPointer)
 Sets the referent for this counter pointer.
void release ()
 Release a reference to the wrapped resource.

Private Attributes

struct
Ceylan::CountedPointer::Referent
_referent
 Second: implementation.


Detailed Description

template<typename T>
class Ceylan::CountedPointer< T >

Definition at line 154 of file CeylanCountedPointer.h.


Member Typedef Documentation

template<typename T>
typedef T Ceylan::CountedPointer< T >::ElementType

The counted object (wrapped resource) type.

Definition at line 165 of file CeylanCountedPointer.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

template<typename T>
Ceylan::CountedPointer< T >::CountedPointer ( ElementType resourcePointer = 0  )  [inline]

template<typename T>
Ceylan::CountedPointer< T >::CountedPointer ( const CountedPointer< T > &  source  )  [inline]

Copy constructor.

The two instances of counted pointer will refer the same referent.

Definition at line 206 of file CeylanCountedPointer.h.

References Ceylan::CountedPointer< T >::_referent, and Ceylan::CountedPointer< T >::setReferent().

template<typename T>
Ceylan::CountedPointer< T >::~CountedPointer (  )  throw () [inline]

Destructor of a counted pointer, decreases the reference count which may lead to deallocation of resource.

Note:
Should not specifically be called explicitly under normal use.

Definition at line 255 of file CeylanCountedPointer.h.

References Ceylan::CountedPointer< T >::release().


Member Function Documentation

template<typename T>
ElementType* Ceylan::CountedPointer< T >::get (  )  const [inline]

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]

template<typename T>
ReferenceCount Ceylan::CountedPointer< T >::getReferenceCount (  )  const [inline]

Returns the reference count for this counted pointer.

Definition at line 322 of file CeylanCountedPointer.h.

References Ceylan::CountedPointer< T >::CountedPointer::Referent::_refCount, and Ceylan::CountedPointer< T >::_referent.

template<typename T>
bool Ceylan::CountedPointer< T >::isUnique (  )  const [inline]

Tells whether the reference count for the wrapped resource is exactly 1.

Definition at line 309 of file CeylanCountedPointer.h.

References Ceylan::CountedPointer< T >::CountedPointer::Referent::_refCount, and Ceylan::CountedPointer< T >::_referent.

template<typename T>
ElementType& Ceylan::CountedPointer< T >::operator* (  )  const [inline]

Dereferences the counted pointer to access the wrapped resource, and returns a reference to this resource.

Definition at line 269 of file CeylanCountedPointer.h.

template<typename T>
ElementType* Ceylan::CountedPointer< T >::operator-> (  )  const [inline]

Returns the wrapped resource pointer.

Definition at line 282 of file CeylanCountedPointer.h.

template<typename T>
CountedPointer<T>& Ceylan::CountedPointer< T >::operator= ( const CountedPointer< T > &  source  )  [inline]

template<typename T>
void Ceylan::CountedPointer< T >::release (  )  [inline, private]

Release a reference to the wrapped resource.

If no reference left, deallocate this unused resource.

Definition at line 554 of file CeylanCountedPointer.h.

References Ceylan::CountedPointer< T >::CountedPointer::Referent::_refCount, Ceylan::CountedPointer< T >::_referent, and CEYLAN_DISPLAY_REFCOUNT.

Referenced by Ceylan::CountedPointer< T >::reset(), and Ceylan::CountedPointer< T >::~CountedPointer().

template<typename T>
void Ceylan::CountedPointer< T >::reset ( Referent refPointer  )  [inline, private]

Each CountedPointer has therefore a member: Referent * _referent ;.

Releases one reference and sets the referent to the specified one.

Definition at line 518 of file CeylanCountedPointer.h.

References Ceylan::CountedPointer< T >::release(), and Ceylan::CountedPointer< T >::setReferent().

Referenced by Ceylan::CountedPointer< T >::operator=().

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

template<typename T>
void Ceylan::CountedPointer< T >::setReferent ( Referent refPointer  )  [inline, private]

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

template<typename T>
virtual const std::string Ceylan::CountedPointer< T >::toString ( VerbosityLevels  level = high  )  const [inline, virtual]


Member Data Documentation

TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().

template<typename T>
struct Ceylan::CountedPointer::Referent * Ceylan::CountedPointer< T >::_referent [private]


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

Generated on Thu Jun 4 20:40:05 2009 for Ceylan by  doxygen 1.5.8