VISH  0.2
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
MemCore::DynPtr< ObjectBase, ObjectBase > Class Reference

Base class for pointers to base classes. More...

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

List of all members.

Public Types

Public Member Functions

Validity Operators
Analyse functions for debugging
Pointer arithmetic

Static Public Member Functions

Protected Member Functions

Protected Attributes

Friends


Detailed Description

Base class for pointers to base classes.

Implements basic operations on pointers.


Constructor & Destructor Documentation

MemCore::DynPtr< ObjectBase, ObjectBase >::~DynPtr ( ) [inline]

Destructor of the dynamic pointer.

It does neither touch the reference counting nor eventually delete the associated object, although it can detect a possible memory leak.

Note that even if the strong reference count is zero, the object is not destroyed.

		Data*Dptr = new Data(10);
		{
			WeakPtr<Data> d = Dptr;
		}
		delete Dptr;
	

Member Function Documentation

const type_info& MemCore::DynPtr< ObjectBase, ObjectBase >::getType ( ) const throw () [inline]

Return type info of associated object,.

  • typeid(void) is returned if the pointer is NULL
bool MemCore::DynPtr< ObjectBase, ObjectBase >::operator== ( const DynPtr< ObjectBase, ObjectBase > &  other) const throw () [inline]

Equality operator.

It compares the adresses of the intermediate reference object, not of the true data object. This enables comparisions with actually deleted objects when the WeakPtr already is invalid: Two invalid WeakPtr<>'s are ONLY equal if they both referred to the same deleted object, otherwise they are UNEQUAL, even if both are invalid and compare true to a NullPtr() !

void MemCore::DynPtr< ObjectBase, ObjectBase >::ref ( ) const [inline]

Increment the reference count.

Note that only semi-positive refcounts are increased. A negative refcount indicates a static or automatic object, i.e. one which does not require any refcounting at all.

Note:
The first referencing to a strong pointer will call deferred_initialize() . This function might possibly throw an exception.
int MemCore::DynPtr< ObjectBase, ObjectBase >::strong_refs ( ) const throw () [inline]

Return the strong reference count, ie.

how many pointers keep the object alive. Note that an negative value indicates a dead object. If the returned values is -2, then there is not even a referer object, ie. no more weak references exist. Actually, this cannot happen and indicates a bug, like intermediate usage of native pointers. Only somewhere in intermediate constuctor code such things are thinkable.

void MemCore::DynPtr< ObjectBase, ObjectBase >::unref ( ) const throw () [inline]

Decrement the reference count.

Once it reaches zero value, the object is inevitably destroyed and the reference count is set to -1 to indicate invalidity. There is no way to reset the reference count from a negative value to a positive one. Any further ref() calls will be ignored, the object is lost forever, but its referer object may still be alive as a zombie placeholder.

int MemCore::DynPtr< ObjectBase, ObjectBase >::weak_refs ( ) const throw () [inline]

Return the weak reference count, ie.

how many references exist to the object. Note that if only weak references exist to an object, it is likely to be a zombie.

void MemCore::DynPtr< ObjectBase, ObjectBase >::wunref ( ) throw () [inline, protected]

Decrement the weak reference count and remove the referer if it reaches zero.

The reference object is removed outside of a thread-critical section because it might involve a non-trivial destructor which e.g. waits for other threads. It were no good if just these threads are just waiting to enter the wunref() routine because this would lead to an infinite hangup.


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