nub::soft_ref< T > Class Template Reference

#include <nub/ref.h>

Inheritance diagram for nub::soft_ref< T >:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 soft_ref (nub::uid i, ref_type tp=STRONG)
 soft_ref (T *master, ref_type tp=STRONG, ref_vis vis=DEFAULT)
template<class U>
 soft_ref (const soft_ref< U > &other)
template<class U>
 soft_ref (const ref< U > &other)
void reset (T *p=0)
 Shorthand for assignment.
T * get () const
T * operator-> () const
T & operator* () const
T * get_weak () const throw ()
ref_type get_ref_type () const throw ()
bool is_valid () const throw ()
bool is_invalid () const throw ()
bool operator== (const soft_ref &other) const throw ()
bool operator!= (const soft_ref &other) const throw ()
bool operator< (const soft_ref &other) const throw ()
 Comparison operator for sorting, to insert in std::map or std::set, etc.
nub::uid id () const throw ()
T * getWeak () const throw ()
bool isValid () const throw ()
bool isInvalid () const throw ()


Detailed Description

template<class T>
class nub::soft_ref< T >

nub::soft_ref<T> is a ref-counted smart pointer (like nub::ref<T>) for holding ref_counted objects. Construction of a nub::soft_ref<T> is guaranteed not to fail. Because of this, however, a nub::soft_ref<T> is not guaranteed to always point to a valid object (this must be tested with is_valid() before dereferencing). With these characteristics, a nub::soft_ref<T> can be used with volatile ref_counted objects for which only weak references are available.

Definition at line 231 of file ref.h.


Member Function Documentation

template<class T>
void nub::soft_ref< T >::reset ( T *  p = 0  )  [inline]

Shorthand for assignment.

Given ref<T> rr and T* p, then rr.reset(p) is shorthand for rr=ref<T>(p). But of course, rr.reset(p) is much less typing if T happens to be spelt SomeLongType<WithTemplateParams>.

Definition at line 270 of file ref.h.

template<class T>
T* nub::soft_ref< T >::get (  )  const [inline]

Returns the pointee, or if throws an exception if there is not a valid pointee.

Definition at line 274 of file ref.h.

Referenced by nub::signal_base::do_connect(), nub::signal_base::do_disconnect(), and nub::ref< nub::slot0 >::operator<().

template<class T>
T* nub::soft_ref< T >::get_weak (  )  const throw () [inline]

Returns the pointee, or returns null if there is not a valid pointee. Will not throw an exception.

Definition at line 281 of file ref.h.

Referenced by GxCache::draw(), and nub::soft_ref< Toglet >::operator<().


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

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:56:23 2008 by Doxygen version 1.5.5.