Oracle Coherence for C++ API
Release 3.6.1.0
E18813-01

- Main Page
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# WeakHolder Class Template Reference

`#include <coherence/lang/WeakHolder.hpp>`

List of all members.

## Detailed Description

### template<class T>
class coherence::lang::WeakHolder< T >

WeakHolders are a TypedHolder like wrapper around WeakReferences.

WeakReferences allow one Object to safely reference another without blocking it from being destroyed. WeakRefereces 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.

WeakHolders are wrappers for MemberHolder, 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 MemberHolder the parent object must inherit from Object.

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

See also:
  MemberHolder

Author:
  mf 2008.12.09

## 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.
typedef T::Holder | ValueHolder
| The associated non-weak Holder type.
## Public Member Functions
| WeakHolder (const Object &oGuardian)
| Construct a WeakHolder referencing NULL.
| WeakHolder (const Object &oGuardian, const TypedHolder< T > &that)
| Construct a WeakHolder referencing an object.
| WeakHolder (const Object &oGuardian, const TypedHolder< T > &that, bool fMutable)
| Construct a WeakHolder referencing an object.
WeakHolder & | operator= (const TypedHolder< T > &that)
| Re-assign the WeakHolder to weakly reference a new Object.
WeakHolder & | operator= (const WeakHolder &that)
| Re-assign the WeakHolder 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 WeakHolder returning a non-weak View.
const T & | operator * () const
| Dereference this handle, returning `T&`.
## Protected Attributes
MemberHolder < WeakReference > | m_ohWeak
| The Holder to the associated WeakReference.
const T * | m_cpWeak
| Raw pointer to the weakly referenced object.

## Constructor & Destructor Documentation

WeakHolder | ( | const Object & | oGuardian | ) | `[inline]`

Construct a WeakHolder referencing NULL.

Parameters:

  | oGuardian | reference to the WeakHolder's parent

WeakHolder | ( | const Object & | oGuardian,
|  | const TypedHolder< T > & | that |
| ) |  |  | `[inline]`

Construct a WeakHolder referencing an object.

Parameters:

  | oGuardian | reference to the WeakHolder's parent
  | that | the object to reference

WeakHolder | ( | const Object & | oGuardian,
|  | const TypedHolder< T > & | that,
|  | bool | fMutable |
| ) |  |  | `[inline]`

Construct a WeakHolder referencing an object.

Parameters:

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

## Member Function Documentation

WeakHolder& operator= | ( | const TypedHolder< T > & | that | ) | `[inline]`

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

Parameters:

  | that | the object to reference

WeakHolder& operator= | ( | const WeakHolder< T > & | that | ) | `[inline]`

Re-assign the WeakHolder 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 WeakHolder 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:

- coherence/lang/WeakHolder.hpp

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.