#include <refclass.h>
Collaboration diagram for RefClass< T, Arg, TStar >:
Public Methods | |
Arg | GetKey () const |
Gets the key from this one's iterator. More... | |
int | getRefCount () const |
Debugging check-- gets the Reference Count. More... | |
RefClass (const Arg &a) | |
The default constructor that calls the private function. More... | |
RefClass () | |
This is the default constructor for this class since we do not allow for NULL. More... | |
RefClass (const RefClass< T, Arg, TStar > &r) | |
This is the refclass copy construcotr...First increments the reference, then assigns the pointers. More... | |
RefClass< T, Arg, TStar > & | operator= (const RefClass< T, Arg, TStar > &r) |
This is the famous gets operator that must increase the reference count before it destroys this object. More... | |
~RefClass () | |
The destructor is simple, just calls the DestroyObject helper used in the gets operator. More... | |
T * | Get () |
This is the Get functon that returns the second. It asserts that things aren't null, but that is not necessary code. More... | |
const T * | Get () const |
This is the Get functon that returns the second. It asserts that things aren't null, but that is not necessary code. More... | |
T * | operator * () |
This is the derefernece-- redirects call to assertion/get. More... | |
const T * | operator * () const |
This is the derefernece--redirects call to assertion/get. More... | |
T * | operator-> () |
This is the derefernece-- redirects call to assertion/get. More... | |
const T * | operator-> () const |
This is the derefernece-- redirects call to assertion/get. More... | |
bool | operator< (const RefClass< T, Arg, TStar > &r) const |
This is the less than operator that just redirects the query to the TStar. More... | |
bool | operator== (const RefClass< T, Arg, TStar > &r) const |
This is the equality operator that just redirects the query to the TStar. More... | |
void | Debug () const |
This prints out address. More... | |
Protected Types | |
enum | SPECIALARG { NOTATHANG } |
So Subclasses can be set to this NULL. More... | |
Protected Methods | |
void | DestroyObject () |
Destroys the object by decrementing reference count and deleting it if necessary.If refcount goes to zero this is our only change to kill the actual class.Not to be used by the outside world because it assumes things are in place, etc. More... | |
void | IncRef () const |
Simply increments the refcount. Does not check if it is an iterator to NiL. More... | |
void | DecRef () const |
Simply decrements the recount. Uses a primitive assert to assure it's not zero. More... | |
RefClass (SPECIALARG dummy, SPECIALARG d) | |
bool | isNull () const |
Checks if this is null; only for use by the subclass. More... | |
void | setNull () |
Sets this to null; only for use by the subclass. More... | |
Protected Attributes | |
TMap::iterator | t |
The iterator that will point to a given thing in a class. More... | |
Static Protected Attributes | |
TMap | NiL |
The NiL function to be compared against when this class is used by the killable subtype. More... | |
TMap | hmap |
This is the static TMap that holds all the arg/T pairs--is pointed to by up to dozens of iterators (based on the refcount)this class relies on the fact that modifying hmap DOES NOT invalidate iterator. W00t! More... | |
Private Types | |
typedef TStar | Tstar |
typedef std::map< Arg, TStar > | TMap |
Private Methods | |
void | TConstruct (const Arg &a) |
Constructs T with an argument of A. Privately owned, not to be used ooutside of RefClass. More... | |
Private Attributes | |
T * | t |
int | refcount |
This class is a simple way to keep track of many objects which share their arguments This is the default type that would reside within a RefClass. It actually inherits from the class involved, thus it may not have any subclassage The advantage is that it needs less dereferencing.
|
|
|
|
|
So Subclasses can be set to this NULL.
00123 {NOTATHANG}; |
|
sets things to null. Not for use except by subclasses Not for general consumption.
|
|
The default constructor that calls the private function.
00138 { 00139 TConstruct(a); 00140 } |
|
This is the default constructor for this class since we do not allow for NULL.
00142 { 00143 TConstruct (Arg()); 00144 } |
|
This is the refclass copy construcotr...First increments the reference, then assigns the pointers.
|
|
The destructor is simple, just calls the DestroyObject helper used in the gets operator.
00150 {DestroyObject();} |
|
This prints out address.
00168 {printf ("0x%x refcount %d content: %s\n",&((*t).second),(*t).second.refcount,(*t).second->print().c_str());} |
|
Simply decrements the recount. Uses a primitive assert to assure it's not zero.
00118 { 00119 (*t).second.refcount--; 00120 REFASSERT((*t).second.refcount>=0); 00121 } |
|
Destroys the object by decrementing reference count and deleting it if necessary.If refcount goes to zero this is our only change to kill the actual class.Not to be used by the outside world because it assumes things are in place, etc.
Reimplemented in RefContainer< T, Arg, TStar >.
|
|
This is the Get functon that returns the second. It asserts that things aren't null, but that is not necessary code.
Reimplemented in RefContainer< T, Arg, TStar >.
|
|
This is the Get functon that returns the second. It asserts that things aren't null, but that is not necessary code.
Reimplemented in RefContainer< T, Arg, TStar >.
|
|
Gets the key from this one's iterator.
00134 {return (*t).first;} |
|
Debugging check-- gets the Reference Count.
00136 {return (*t).second.refcount;} |
|
Simply increments the refcount. Does not check if it is an iterator to NiL.
00116 {(*t).second.refcount++;} |
|
Checks if this is null; only for use by the subclass.
|
|
This is the derefernece--redirects call to assertion/get.
Reimplemented in RefContainer< T, Arg, TStar >.
00158 {return Get();} |
|
This is the derefernece-- redirects call to assertion/get.
Reimplemented in RefContainer< T, Arg, TStar >.
00156 {return Get();} |
|
This is the derefernece-- redirects call to assertion/get.
00162 {return Get();} |
|
This is the derefernece-- redirects call to assertion/get.
00160 {return Get();} |
|
This is the less than operator that just redirects the query to the TStar.
00164 {return (*t).second<(*r.t).second;} |
|
This is the famous gets operator that must increase the reference count before it destroys this object.
00148 {r.IncRef();DestroyObject();t=r.t;return *this;} |
|
This is the equality operator that just redirects the query to the TStar.
00166 {return (*t).second==(*r.t).second;} |
|
Sets this to null; only for use by the subclass.
|
|
Constructs T with an argument of A. Privately owned, not to be used ooutside of RefClass.
|
|
This is the static TMap that holds all the arg/T pairs--is pointed to by up to dozens of iterators (based on the refcount)this class relies on the fact that modifying hmap DOES NOT invalidate iterator. W00t!
|
|
The NiL function to be compared against when this class is used by the killable subtype.
|
|
|
|
|
|
The iterator that will point to a given thing in a class.
|