Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

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. WeakReferences 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. Additionally 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 owning "parent" Object. As with MemberView the parent object must inherit from Object.

Note: In the rare case that a WeakView is declared via the mutable keyword, the WeakView must be informed of this fact by setting fMutable to true during construction.

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 ValueHandle
 The associated non-weak Handle type.
typedef T::View ValueView
 The associated non-weak View type.

Public Member Functions

 WeakView (const Object &oGuardian)
 Construct a WeakView referencing NULL.
 WeakView (const Object &oGuardian, const TypedHandle< const T > &that)
 Construct a WeakView referencing an object.
 WeakView (const Object &oGuardian, const TypedHandle< const T > &that, bool fMutable)
 Construct a WeakView referencing an object.
WeakViewoperator= (const TypedHandle< const T > &that)
 Re-assign the WeakView to weakly reference a new Object.
WeakViewoperator= (const WeakView &that)
 Re-assign the WeakView to weakly reference a new Object.
 operator ValueView () const
 Return a non-weak View to the weakly referenced Object, or a View to NULL if the weakly referenced Object has been destroyed.
template<class PT>
 o () const
 Return a View to the referenced Object.
template<class PT>
 o () const
 Return a TypedHolder to the referenced Object.
ValueView operator-> () const
 Dereference the WeakView returning a non-weak View.
const T & operator * () const
 Dereference this handle, returning T&.

Protected Attributes

MemberView
< WeakReference
m_vWeak
 The View to the associated WeakReference.
const T * m_cpWeak
 Raw pointer to the weakly referenced object.

Constructor & Destructor Documentation

WeakView ( const Object oGuardian  )  [inline]

Construct a WeakView referencing NULL.

Parameters:
 oGuardian reference to the WeakView's parent

WeakView ( const Object oGuardian,
    const TypedHandle< const T > &  that 
  )    [inline]

Construct a WeakView referencing an object.

Parameters:
 oGuardian reference to the WeakView's parent
 that the object to reference

WeakView ( const Object oGuardian,
    const TypedHandle< const T > &  that,
    bool  fMutable 
  )    [inline]

Construct a WeakView referencing an object.

Parameters:
 oGuardian reference to the WeakView's parent
 that the object to reference
 fMutable true if the member is declared as mutable, false if declared as const


Member Function Documentation

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

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

Parameters:
 that the object to reference

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

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

Parameters:
 that the object to reference

operator ValueView (  )  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:
ValueView

o (  )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

o (  )  const [inline]

Return a TypedHolder to the referenced Object.

Returns:
a TypedHolder to the referenced Object

ValueView operator-> (  )  const [inline]

Dereference the WeakView returning a non-weak View.

If the non-weak View is non-NULL then it is guaranteed 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

const T& operator * (  )  const [inline]

Dereference this handle, returning T&.

Returns:
a raw T& reference to the referenced Object
Exceptions:
 NullPointerException if the this handle is NULL


The documentation for this class was generated from the following file:
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.