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

strmod::lcore::ReferenceCounting Class Reference

A base mixin class for reference counted things. More...

#include <LCore/RefCounting.h>

Inheritance diagram for strmod::lcore::ReferenceCounting:

Inheritance graph
[legend]
List of all members.

Public Methods

 ReferenceCounting (U4Byte refs)
 Initialize with a reference count.

virtual ~ReferenceCounting ()
 Not much to do on destruction.

virtual int AreYouA (const ClassIdent &cid) const
void AddReference ()
 Add a reference to the count.

void DelReference ()
 Remove a reference from the count and stop the counter from rolling over backwards.

U4Byte NumReferences () const
 How many references?


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.

void AddReferences (U4Byte num)
 Add more than 1 reference.

void DelReferences (U4Byte num)
 Remove more than 1 reference, again with protection from rolling over backwards.


Detailed Description

A base mixin class for reference counted things.

There are many ways to handle reference counting as a general garbage collection technique in C++. This helps implement one of the more efficient, but also somewhat invasive ones. This one has the reference count stored inside the class itself. This means the class holds data that really doesn't have much to do with the class, but some classes are designed to be used in ways where you know reference counting will be needed and useful as a garbage collection technique.

This class has an associated smart pointer class, RefCountPtr, that can be used to point at instances of this class. The smart pointer class will track references for you. But, there is no requirement to use it if you want to do your reference counting in some other way.

Definition at line 76 of file RefCounting.h.


Member Function Documentation

void strmod::lcore::ReferenceCounting::DelReference   [inline]
 

Remove a reference from the count and stop the counter from rolling over backwards.

Note that this class does not consider it it's job to actually delete itself when the reference count goes to 0. That job is more properly left to the smart pointer class.

Definition at line 98 of file RefCounting.h.

const ClassIdent * strmod::lcore::ReferenceCounting::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::Event, strmod::strmod::BufferChunk, strmod::strmod::DynamicBuffer, strmod::strmod::EOFStrChunk, strmod::strmod::GroupChunk, strmod::strmod::PreAllocBufferBase, strmod::strmod::SocketModuleChunk, strmod::strmod::StaticBuffer, strmod::strmod::StrChunk, strmod::strmod::StrSubChunk, strmod::strmod::TelnetChunker::TelnetData, strmod::strmod::TelnetChunker::SingleChar, strmod::strmod::TelnetChunker::Suboption, and strmod::strmod::TelnetChunker::OptionNegotiation.

Definition at line 114 of file RefCounting.h.


Member Data Documentation

const LCore_ClassIdent strmod::lcore::ReferenceCounting::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::Event, strmod::strmod::BufferChunk, strmod::strmod::DynamicBuffer, strmod::strmod::EOFStrChunk, strmod::strmod::GroupChunk, strmod::strmod::PreAllocBufferBase, strmod::strmod::SocketModuleChunk, strmod::strmod::StaticBuffer, strmod::strmod::StrChunk, strmod::strmod::StrSubChunk, strmod::strmod::TelnetChunker::TelnetData, strmod::strmod::TelnetChunker::SingleChar, strmod::strmod::TelnetChunker::Suboption, and strmod::strmod::TelnetChunker::OptionNegotiation.


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