WeakView Class Template Reference

#include <coherence/lang/WeakView.hpp>

List of all members.


Detailed Description

template<class T>
class coherence::lang::WeakView< T >

WeakViews are a TypedHandle like wrapper around WeakReferences.

WeakReferences allow one Object to safely reference another without blocking it from being destroyed. WeakRefere ces are necessary when building Object graphs to avoid leaking the Object graph due to cyclical references.

WeakReferences are automatically NULL'd out when their referenced Object is destroyed. Addionally if the weakly referenced Object becomes only referenced via Views, then the WeakReference and corresponding WeakHandle will only return View to the Object, if an attempt is made to obtain a Handle a NULL will be returned instead.

WeakViews are wrappers for MemberView, and provide a thread-safe handle implementation. As such they require references to both the referenced "child" Object, as well as the ownening "parent" Object. As with MemberView the parent object must inherit from Object.

See also:
MemberView
Author:
mf 2007.07.05

Public Types

typedef const T ValueType
 The type of Object which this handle weakly references.
typedef T::Handle OuterHandle
 The associated non-weak Handle type.
typedef T::View OuterView
 The associated non-weak View type.
typedef MemberView
< WeakReference
InnerView
 The View used to hold the internal WeakReference.

Public Member Functions

 WeakView (Object &oParent)
 Construct a WeakView referencing NULL.
 WeakView (Object &oParent, OuterHandle h)
 Construct a WeakView from a normal Handle.
 WeakView (Object &oParent, OuterView v)
 Construct a WeakView from a normal View.
OuterView operator-> () const
 Dereference the WeakView returning a non-weak View.
WeakView< T > & operator= (const OuterView &v)
 Re-assign the WeakView to weakly reference a new Object.
WeakView< T > & operator= (const OuterHandle &h)
 Re-assign the WeakView to weakly reference a new Object.
WeakView< T > & operator= (const WeakView< T > &wv)
 Re-assign the WeakView.
WeakView< T > & operator= (const WeakHandle< T > &wh)
 Re-assign the WeakView.
 operator OuterView () const
 Return a non-weak View to the weakly referenced Object, or a View to NULL if the weakly referenced Object has been destroyed.
bool operator< (const WeakView< T > &wvThat) const
 Compare two WeakView with "less-than" predicate.
bool operator== (const WeakView< T > &wvThat) const
 Compare two WeakViews for equality.
bool operator!= (const WeakView< T > &wvThat) const
 Compare two WeakViews for inequality.
bool operator== (const OuterView &v) const
 Compare two Views for equality.
bool operator!= (const OuterView &v) const
 Compare two Views for inequality.
bool operator== (const Object *o) const
 Compare this View with the raw const pointer for equality.
bool operator!= (const Object *o) const
 Compare this View with the raw const pointer for inequality.

Protected Attributes

InnerView m_vWeak
 The View to the assocaited WeakReference.

Constructor & Destructor Documentation

WeakView ( Object oParent  )  [inline]

Construct a WeakView referencing NULL.

Parameters:
oParent reference to the WeakView's parent

WeakView ( Object oParent,
OuterHandle  h 
) [inline]

Construct a WeakView from a normal Handle.

Parameters:
h a Handle to the Object to reference
oParent reference to the WeakView's parent

WeakView ( Object oParent,
OuterView  v 
) [inline]

Construct a WeakView from a normal View.

Parameters:
v a View to the Object to reference
oParent reference to the WeakView's parent


Member Function Documentation

OuterView operator-> (  )  const [inline]

Dereference the WeakView returning a non-weak View.

If the non-weak View is non-NULL then it is guarenteed that the Object will continue to exist for at least the life of the returned View.

Returns:
a non-weak View to the referenced Object

WeakView<T>& operator= ( const OuterView v  )  [inline]

Re-assign the WeakView to weakly reference a new Object.

Parameters:
v a View to the Object to weakly reference

WeakView<T>& operator= ( const OuterHandle h  )  [inline]

Re-assign the WeakView to weakly reference a new Object.

Parameters:
h a View to the Object to weakly reference

WeakView<T>& operator= ( const WeakView< T > &  wv  )  [inline]

Re-assign the WeakView.

Parameters:
wv a WeakView to the Object to weakly reference

WeakView<T>& operator= ( const WeakHandle< T > &  wh  )  [inline]

Re-assign the WeakView.

Parameters:
wh a WeakHandle to the Object to weakly reference

operator OuterView (  )  const [inline]

Return a non-weak View to the weakly referenced Object, or a View to NULL if the weakly referenced Object has been destroyed.

Returns:
OuterView

bool operator== ( const Object o  )  const [inline]

Compare this View with the raw const pointer for equality.

Returns:
true iff the handle and the pointer reference the same Object

bool operator!= ( const Object o  )  const [inline]

Compare this View with the raw const pointer for inequality.

Returns:
false iff the handle and the pointer reference the same Object


The documentation for this class was generated from the following file: Copyright (c) 2000-2008 Oracle. All rights reserved.