Oracle Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.2)

E26041-01

WeakHandle Class Template Reference

#include <coherence/lang/WeakHandle.hpp>

List of all members.


Detailed Description

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

WeakHandles 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 cyclic 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.

WeakHandles behave like MemberHandles by transferring their constness to their referenced Object. As with MemberHandle WeakHandles are 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.

If the weakly referenced Object will always be referenced as a View then using the WeakView class would be more appropriate

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

See also:
MemberHandle

WeakView

Author:
mf 2007.07.05

Public Types

typedef 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.
typedef MemberHandle
< WeakReference
InnerHandle
 The MemberHandle used to hold the internal WeakReference.
typedef ValueHandle GetType
 Result type for a non-const get operation.
typedef ValueView ConstGetType
 Result type for a non-const get operation.

Public Member Functions

 WeakHandle (const Object &oGuardian)
 Default constructor.
 WeakHandle (const Object &oGuardian, const TypedHandle< T > &that)
 Construct a WeakHandle from a normal Handle.
 WeakHandle (const Object &oGuardian, const TypedHandle< T > &that, bool fMutable)
 Construct a WeakHandle from a normal Handle.
WeakHandleoperator= (const TypedHandle< T > &that)
 Re-assign the WeakHandle to weakly reference a new Object.
WeakHandleoperator= (WeakHandle &that)
 Assign this WeakHandle to reference the same Object as the specified WeakHandle.
 operator ValueHandle ()
 Return a non-weak Handle to the weakly referenced Object, or a Handle to NULL if the weakly referenced Object has been destroyed or is now only referenced via Views.
 operator ValueView () const
 Return a non-weak View to the weakly referenced Object, or a Handle 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 ()
 Return a Handle to the referenced Object.
template<class PT>
 o () const
 Return a TypedHolder to the referenced Object.
template<class PT>
 o ()
 Return a TypedHolder to the referenced Object.
ValueHandle operator-> ()
 Dereference the WeakHandle returning a non-weak Handle.
ValueView operator-> () const
 Dereference the WeakHandle returning a non-weak View.
const T & operator * () const
 Dereference this handle, returning T&.
T & operator * ()
 Dereference this handle, returning T&.

Protected Attributes

InnerHandle m_hWeak
 The Handle to the associated WeakReference.
T * m_pWeak
 Raw pointer to the weakly referenced object.

Constructor & Destructor Documentation

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

Construct a WeakHandle from a normal Handle.

Parameters:
oGuardian the self() on the object this data member is a member of
that the object to reference

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

Construct a WeakHandle from a normal Handle.

Parameters:
oGuardian the self() on the object this data member is a member of
that the object to reference
fMutable true if the member is declared as mutable, false if declared as const


Member Function Documentation

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

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

Parameters:
that the object to reference

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

Assign this WeakHandle to reference the same Object as the specified WeakHandle.

Parameters:
that the object to reference
Returns:
a reference to this MemberHandle

operator ValueHandle (  )  [inline]

Return a non-weak Handle to the weakly referenced Object, or a Handle to NULL if the weakly referenced Object has been destroyed or is now only referenced via Views.

Returns:
ValueHandle

operator ValueView (  )  const [inline]

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

Returns:
ValueHandle

o (  )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

o (  )  [inline]

Return a Handle to the referenced Object.

Returns:
a Handle to the referenced Object

o (  )  const [inline]

Return a TypedHolder to the referenced Object.

Returns:
a TypedHolder to the referenced Object

o (  )  [inline]

Return a TypedHolder to the referenced Object.

Returns:
a TypedHolder to the referenced Object

ValueHandle operator-> (  )  [inline]

Dereference the WeakHandle returning a non-weak Handle.

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

Returns:
ValueHandle

ValueView operator-> (  )  const [inline]

Dereference the WeakHandle returning a non-weak View.

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

Returns:
ValueHandle

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

T& operator * (  )  [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, 2013, Oracle and/or its affiliates. All rights reserved.