Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

strmod::lcore::RefCountPtr Class Reference

A smart pointer class that points to objects of type ReferenceCounting and maintains their reference counts. More...

#include <LCore/RefCountPtr.h>

Inheritance diagram for strmod::lcore::RefCountPtr:

Inheritance graph
[legend]
List of all members.

Public Types

typedef ReferenceCounting RC

Public Methods

 RefCountPtr ()
 Contruct a null pointer.

 RefCountPtr (RC *rfptr)
 Construct a pointer pointing at rfptr and increment its reference count.

 RefCountPtr (const RefCountPtr &b)
 Copy a RefCountPtr and incremement the reference count of the thing pointed to.

virtual ~RefCountPtr ()
 Destroy the pointer and decrement the reference count of the thing pointed to.

virtual int AreYouA (const lcore::ClassIdent &cid) const
 Asks if a class is of a particular type, or publicly derived from that type.

RC & operator * () const
 Smart pointer operator, if _LCORE_RefCountPtr_H_DEBUG is set, asserts non-null.

RC * operator-> () const
 Smart pointer operator, if _LCORE_RefCountPtr_H_DEBUG is set, asserts non-null.

RC * GetPtr () const
 What am I pointing at?

void ReleasePtr (bool deleteref=true)
 Set me to point at null, decrement the reference count of previous pointer destination.

 operator bool () const
 Am I non-null?

bool operator! () const
 Am I null?

const RefCountPtr & operator= (const RefCountPtr &b)
 Copy a reference counted pointer, handling reference counts appropriately.

const RefCountPtr & operator= (RC *b)
 Copy from a regular pointer, handling reference counts appropriately.


Static Public Attributes

const LCore_ClassIdent identifier
 Globally unique identifier for this class.


Protected Methods

virtual const ClassIdent * i_GetIdent () const
 Returns the class identifier for the class the object actually is.

virtual RC * i_CheckType (RC *p) const
 Do some type checking of a ReferenceCounting pointer to make sure it points at the right type.

void i_SetPtr (ReferenceCounting *p, bool deleteref=true)
 Change what this RefCountPtr points to, maybe modifying reference counts.


Detailed Description

A smart pointer class that points to objects of type ReferenceCounting and maintains their reference counts.

There's not much more to this than the brief description says.

Definition at line 58 of file RefCountPtr.h.


Constructor & Destructor Documentation

strmod::lcore::RefCountPtr::~RefCountPtr   [inline, virtual]
 

Destroy the pointer and decrement the reference count of the thing pointed to.

If the reference count of the thing pointed to goes to 0, its destructor will be called.

Definition at line 168 of file RefCountPtr.h.


Member Function Documentation

virtual int strmod::lcore::RefCountPtr::AreYouA const lcore::ClassIdent &    cid const [inline, virtual]
 

Asks if a class is of a particular type, or publicly derived from that type.

Overriden in every derived class (with a static identifier member) to compare against the identifier, then call the AreYouA methods of all the superclasses.

Parameters:
cid Usually <class>::identifier for the class you want to ask if the object is an instance of.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::strmod::StrChunkPtr.

virtual RC* strmod::lcore::RefCountPtr::i_CheckType RC *    p const [inline, protected, virtual]
 

Do some type checking of a ReferenceCounting pointer to make sure it points at the right type.

Parameters:
p The pointer who's type needs to be checked.
Returns:
null if the pointer is the wrong type, the value of p if it is of the right type.

Definition at line 130 of file RefCountPtr.h.

virtual const ClassIdent* strmod::lcore::RefCountPtr::i_GetIdent   const [inline, protected, virtual]
 

Returns the class identifier for the class the object actually is.

Should always be overridden in any class that has a static identifier member.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::unievent::EventPtr, and strmod::strmod::StrChunkPtr.

Definition at line 123 of file RefCountPtr.h.

void strmod::lcore::RefCountPtr::i_SetPtr ReferenceCounting   p,
bool    deleteref = true
[protected]
 

Change what this RefCountPtr points to, maybe modifying reference counts.

This will properly handle i_SetPtr(GetPtr()). Normally, it will increment the reference count of the new value of the pointer, then decrement the reference count of the old value, possibly deleting the pointed to object if the reference count goes to 0. If deleteref is false, the decrement won't happen.

Parameters:
p The new value of the pointer.
deleteref Should the old value's reference count be decremented?

Definition at line 52 of file rfcntptr.cxx.

const RefCountPtr & strmod::lcore::RefCountPtr::operator= RC *    b [inline]
 

Copy from a regular pointer, handling reference counts appropriately.

This handles *this = this->GetPtr() properly. It decrements the reference count of, and possibly destroys what's currently being pointed at, and increments the reference count of what will be pointed to.

This also uses the i_CheckType() function to do some type checking of the pointer being pointed to. This is so new pointer classes with type constraints can be derived from this class.

Definition at line 223 of file RefCountPtr.h.

const RefCountPtr & strmod::lcore::RefCountPtr::operator= const RefCountPtr &    b [inline]
 

Copy a reference counted pointer, handling reference counts appropriately.

This handles *this = *this, and *this = ReferenceCounting(*this) properly. It decrements the reference count of, and possibly destroys what's currently being pointed at, and increments the reference count of what will be pointed to.

This also uses the i_CheckType() function to do some type checking of the pointer being pointed to. This is so new pointer classes with type constraints can be derived from this class.

Definition at line 213 of file RefCountPtr.h.

void strmod::lcore::RefCountPtr::ReleasePtr bool    deleteref = true [inline]
 

Set me to point at null, decrement the reference count of previous pointer destination.

If the reference count of the thing previously pointed to goes to 0, its destructor will be called.

Definition at line 198 of file RefCountPtr.h.


Member Data Documentation

const LCore_ClassIdent strmod::lcore::RefCountPtr::identifier [static]
 

Globally unique identifier for this class.

Every class that might need to be identified should have a public static const identifier object in it.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::unievent::EventPtr, and strmod::strmod::StrChunkPtr.


The documentation for this class was generated from the following files:
Generated on Wed Jan 29 00:32:48 2003 for libNet by doxygen1.3-rc1