class WeakReference

The WeakReference class can be used to savely store an object, without disallowing that it gets destroyed. More...

Full nameArts::WeakReference
Definition#include <arts/weakreference.h>
Template formWeakReference<templateclass SmartWrapper>
InheritsArts::WeakReferenceBase [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

The WeakReference class can be used to savely store an object, without disallowing that it gets destroyed. A typical situation where you may want to use this is when you implement a datastructure, where A refers B, and B refers A. Using "normal" references, this structure would never get freed.

Usage example:

Synth_WAVE_SIN sin; WeakReference<Synth_PLAY_WAV> weak_sin;

{ Synth_WAVE_SIN test = weak_sin; if(test.isNull()) printf("#1 missing object\n"); else test.start(); }

// now, the strong reference leaves sin = Synth_WAVE_SIN::null();

{ Synth_WAVE_SIN test = weak_sin; if(test.isNull()) printf("#2 missing object\n"); else test.stop();

This would output "#2 missing object".

 WeakReference ()

 WeakReference (const WeakReference<SmartWrapper>& source)

 WeakReference (SmartWrapper& source)

inline WeakReference<SmartWrapper>&  operator= (const WeakReference<SmartWrapper>& source)

 ~WeakReference ()

[virtual]

void  release ()

Reimplemented from WeakReferenceBase.

inline operator  SmartWrapper ()

[const]


Generated by: stefan@stefan on Sat Feb 24 19:11:23 2001, using kdoc 2.0a47.