Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

MemberHolder Class Template Reference

#include <coherence/lang/MemberHolder.hpp>

Inherits SmartMember.

Inherited by FinalHolder.

List of all members.


Detailed Description

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

MemberHolder is a thread-safe handle implementation which supports referencing Objects as either Handles or Views.

MemberHolder can safely be used in place of View but adds the ability to attempt a safe down cast to a Handle. This differs from the C++ const_cast in that the down cast will only succeed if the MemberHolder had been assigned from a Handle, an assignment from a View results in a MemberHolder whose down cast operation will throw a ClassCastException.

MemberHolder is not for general use, instead it is a convenience handle type which can be used for container like classes, which need to be able to contain both Handles and Views.

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

Author:
mf 2008.01.09
 

Public Types

typedef const T ValueType
 The type of the values the holder can reference.
typedef T::Handle ValueHandle
 The Handle type for the referenced Object.
typedef T::View ValueView
 The View type for the referenced Object.
typedef T::Holder ValueHolder
 The Holder type for the referenced Object.
typedef TypedHolder< T > GetType
 Result type for a non-const get operation.

Public Member Functions

 MemberHolder (const Object &oGuardian)
 Construct a new MemberHolder referencing NULL via a handle.
 MemberHolder (const Object &oGuardian, const TypedHolder< T > &that)
 Construct a new MemberHolder referencing the specified Object.
 MemberHolder (const Object &oGuardian, const TypedHolder< T > &that, bool fMutable)
 Construct a new MemberHolder referencing the specified Object.
 ~MemberHolder ()
 Destroy the MemberHolder.
MemberHolderoperator= (const MemberHolder &that)
 Assign this MemberHolder to reference the same Object (and in the same manner) as the specified MemberHolder.
MemberHolderoperator= (const TypedHolder< T > &that)
 Assign this MemberHolder to reference the same Object (and in the same manner) as the specified MemberHolder.
 operator ValueView () const
 Return a View to the referenced Object.
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 MemberHolder.
const T & operator * () const
 Dereference this handle, returning T&.

Protected Member Functions

 MemberHolder ()
 Construct a MemberHolder without any associated guardian.
virtual void onEscape (bool fEscaped) const
 Event called when the guarding Object's escape state changes.

Derived implementations of this method should include a delegation call to their super class onEscape() method, after they've done their own processing of the event.

Parameters:
 fEscaped true if the object is being escaped, false if the object is being captured
void set (const TypedHolder< T > &that, SynchronizedMemberWriteBlock *pSync=NULL)
 Set the Holder to reference an Object via a View.
TypedHolder< T > get (SynchronizedMemberReadBlock *pSync=NULL) const
 Return a TypedHolder referencing the same Object as this MemberHolder.

Protected Attributes

bool m_fView
 True iff a View is held, i.e.
T * m_po
 The referenced Object.

Constructor & Destructor Documentation

MemberHolder ( const Object oGuardian  )  [inline]

Construct a new MemberHolder referencing NULL via a handle.

Parameters:
 oGuardian the object that protects this member

MemberHolder ( const Object oGuardian,
    const TypedHolder< T > &  that 
  )    [inline]

Construct a new MemberHolder referencing the specified Object.

Parameters:
 oGuardian the object that protects this member
 that the Object to reference

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

Construct a new MemberHolder referencing the specified Object.

Parameters:
 oGuardian the object that protects this member
 that the Object to reference
 fMutable true if the member is declared as mutable, false if declared as const

MemberHolder (  )  [inline, protected]

Construct a MemberHolder without any associated guardian.

The new MemberHolder is not usable until the guardian is specified.


Member Function Documentation

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

Assign this MemberHolder to reference the same Object (and in the same manner) as the specified MemberHolder.

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

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

Assign this MemberHolder to reference the same Object (and in the same manner) as the specified MemberHolder.

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

operator ValueView (  )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

Reimplemented in FinalHolder, FinalHolder< coherence::util::ConverterCollections::ConverterQueryMap >, FinalHolder< coherence::util::Set >, FinalHolder< coherence::util::ConverterCollections::ConverterInvocableMap >, FinalHolder< coherence::util::SafeHashMap >, FinalHolder< coherence::util::List >, FinalHolder< coherence::util::Iterator >, FinalHolder< coherence::util::Map::Entry >, FinalHolder< coherence::util::Collection >, FinalHolder< coherence::util::ConverterCollections::ConverterConcurrentMap >, FinalHolder< coherence::util::Map >, and FinalHolder< coherence::util::ListIterator >.

o (  )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

Reimplemented in FinalHolder, FinalHolder, FinalHolder< coherence::util::ConverterCollections::ConverterQueryMap >, FinalHolder< coherence::util::ConverterCollections::ConverterQueryMap >, FinalHolder< coherence::util::Set >, FinalHolder< coherence::util::Set >, FinalHolder< coherence::util::ConverterCollections::ConverterInvocableMap >, FinalHolder< coherence::util::ConverterCollections::ConverterInvocableMap >, FinalHolder< coherence::util::SafeHashMap >, FinalHolder< coherence::util::SafeHashMap >, FinalHolder< coherence::util::List >, FinalHolder< coherence::util::List >, FinalHolder< coherence::util::Iterator >, FinalHolder< coherence::util::Iterator >, FinalHolder< coherence::util::Map::Entry >, FinalHolder< coherence::util::Map::Entry >, FinalHolder< coherence::util::Collection >, FinalHolder< coherence::util::Collection >, FinalHolder< coherence::util::ConverterCollections::ConverterConcurrentMap >, FinalHolder< coherence::util::ConverterCollections::ConverterConcurrentMap >, FinalHolder< coherence::util::Map >, FinalHolder< coherence::util::Map >, FinalHolder< coherence::util::ListIterator >, and FinalHolder< coherence::util::ListIterator >.

o (  )  const [inline]

Return a TypedHolder to the referenced Object.

Returns:
a TypedHolder to the referenced Object

Reimplemented in FinalHolder, FinalHolder, FinalHolder< coherence::util::ConverterCollections::ConverterQueryMap >, FinalHolder< coherence::util::ConverterCollections::ConverterQueryMap >, FinalHolder< coherence::util::Set >, FinalHolder< coherence::util::Set >, FinalHolder< coherence::util::ConverterCollections::ConverterInvocableMap >, FinalHolder< coherence::util::ConverterCollections::ConverterInvocableMap >, FinalHolder< coherence::util::SafeHashMap >, FinalHolder< coherence::util::SafeHashMap >, FinalHolder< coherence::util::List >, FinalHolder< coherence::util::List >, FinalHolder< coherence::util::Iterator >, FinalHolder< coherence::util::Iterator >, FinalHolder< coherence::util::Map::Entry >, FinalHolder< coherence::util::Map::Entry >, FinalHolder< coherence::util::Collection >, FinalHolder< coherence::util::Collection >, FinalHolder< coherence::util::ConverterCollections::ConverterConcurrentMap >, FinalHolder< coherence::util::ConverterCollections::ConverterConcurrentMap >, FinalHolder< coherence::util::Map >, FinalHolder< coherence::util::Map >, FinalHolder< coherence::util::ListIterator >, and FinalHolder< coherence::util::ListIterator >.

ValueView operator-> (  )  const [inline]

Dereference the MemberHolder.

Returns:
a const pointer to the referenced Object

Reimplemented in FinalHolder, FinalHolder< coherence::util::ConverterCollections::ConverterQueryMap >, FinalHolder< coherence::util::Set >, FinalHolder< coherence::util::ConverterCollections::ConverterInvocableMap >, FinalHolder< coherence::util::SafeHashMap >, FinalHolder< coherence::util::List >, FinalHolder< coherence::util::Iterator >, FinalHolder< coherence::util::Map::Entry >, FinalHolder< coherence::util::Collection >, FinalHolder< coherence::util::ConverterCollections::ConverterConcurrentMap >, FinalHolder< coherence::util::Map >, and FinalHolder< coherence::util::ListIterator >.

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

void set ( const TypedHolder< T > &  that,
    SynchronizedMemberWriteBlock pSync = NULL 
  )    [inline, protected]

Set the Holder to reference an Object via a View.

Parameters:
 that the Object to reference
 pSync the synch block to delegate to or NULL to create one

TypedHolder<T> get ( SynchronizedMemberReadBlock pSync = NULL  )  const [inline, protected]

Return a TypedHolder referencing the same Object as this MemberHolder.

Parameters:
 pSync the sync block to delegate to or NULL to create one
Returns:
a TypedHolder referencing the same Object as this MemberHolder


Member Data Documentation

bool m_fView [protected]

True iff a View is held, i.e.

down casting to a Handle is not allowed.


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