VISH  0.2
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
MemCore::ReferenceBase Class Reference

Base class for objects which do reference counting. More...

#include </home/werner/origo/vish/memcore/RefPtr.hpp>

List of all members.

Public Types

Public Member Functions

Static Public Member Functions

Protected Member Functions

Friends


Detailed Description

Base class for objects which do reference counting.

Contains a reference counter, to be used with the RefPtr<> template.

See also:
WeakPtr, StrongPtr
Note:
When a child class is derived from multiple base classes, the ReferenceBase<> class should be the first one. This is required for memory leak debugging purposes, where the internal object tracer only stores void pointers

Member Function Documentation

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.

const WeakPtr<Object, Object>& MemCore::ReferenceBase::self ( ) const [inline]

Return weak pointer to the object self.

Same functionality as the address operator, but better ;-).


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