VISH
0.2
|
Base class for objects which do reference counting. More...
#include </home/werner/origo/vish/memcore/RefPtr.hpp>
Base class for objects which do reference counting.
Contains a reference counter, to be used with the RefPtr<> template.
long MemCore::ReferenceBase::getObjectCountID | ( | ) | const throw () [inline] |
Get a unique ID for this object in the given domain.
Each ReferenceBase gets a unique such number. This object count ID serves like a unique pointer to each object, but moreover is unique for the object even if another one was living at the same memory address some time before.
void MemCore::ReferenceBase::mkAutoDestructive | ( | ) | [inline] |
Marks this object as being automatically destructed, e.g.
it is a static or automatic variable, or it is deleted explicetly. This call increments the strong reference count, such that its lifetime is preserved over all strong pointers referring to this object.
This function is identical to calling self().ref()
. The effect can be reversed by calling self().unref()
, which might destroy the object in charge if no other strong pointer refers to this object. In general, there is no need to call the unref() function. Its only purpose where to keep the object alive temporarily with no strong pointer referring to it; usually, it should be simpler to just introduce a strong pointer. On the other hand, the ref() call makes sense for automatic or static objects, where "the system" holds a (not-strong) pointer to the object.
void MemCore::ReferenceBase::operator= | ( | const ReferenceBase & | R | ) | [inline, protected] |
Protected assignment operator (should not be called).
Leaves references untouched. We may assume that some child data are copied from the other reference object, but that the references to this object by itself are unchanged, i.e. just the data change due to the assigment operation, but not the references.
Return weak pointer to the object self.
Same functionality as the address operator, but better ;-).