Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

MemberHandle Class Template Reference

#include <coherence/lang/MemberHandle.hpp>

Inherits SmartMember.

Inherited by FinalHandle.

List of all members.


Detailed Description

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

MemberHandle is a thread-safe handle used by an Object to reference its non-const child Objects.

MemberHandles transfer the constness of their guardian Object. When a MemberHandle is accessed from within a const method of the enclosing "parent" class, it will only provide const access to the Object which it references. If the enclosing Object becomes only accessed via views the MemberHandle will also automatically, and permanently switch its reference type from a handle to a view.

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

Author:
mf 2007.07.05
See also:
MemberView

MemberHolder

 

Public Types

typedef T  ValueType
  The type of the values the handle 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 ValueHandle  GetType
  Result type for a non-const get operation.
typedef ValueView  ConstGetType
  Result type for a non-const get operation.

Public Member Functions

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

Protected Member Functions

void  set (const TypedHandle< T > &that, SynchronizedMemberWriteBlock *pSync=NULL)
  Set the MemberHandle to reference the same Object as the supplied Handle.
ValueView  get (SynchronizedMemberReadBlock *pSync=NULL) const
  Return a View to the referenced Object.
ValueHandle  get (SynchronizedMemberReadBlock *pSync=NULL)
  Return a Handle to the referenced Object.
virtual void  onConst ()
  Event called when the guardian Object becomes only referenced via const pointers (Views).

As the SmartMember is a data-member of this Object, the data-member infer that only const methods will be called from now on.

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

Not that this method will only be called by the guardian if the SmartMember's mutability state is set to inherited.

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

Protected Attributes

T *  m_po
  The referenced Object.

Friends

template<class D, class H>
cast (MemberHandle< T > &mh, bool fThrow)
  Perform a dynamic cast the pointer associated with the MemberHandle to a the specified handle/view type.

Constructor & Destructor Documentation

MemberHandle ( const Object oGuardian  )  [inline]

Construct a new MemberHandle referencing NULL via a handle.

Parameters:
  oGuardian  the object that protects this member

MemberHandle ( const Object oGuardian,
    const ValueHandle that  
  )     [inline]

Construct a new MemberHandle referencing the specified Object via a handle.

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

MemberHandle ( const Object oGuardian,
    const ValueHandle that,
    bool  fMutable  
  )     [inline]

Construct a new MemberHandle referencing the specified Object via a handle.

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

Member Function Documentation

MemberHandle& operator= ( const ValueHandle that  )  [inline]

Assign the MemberHandle to reference another object.

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

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

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

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

operator ValueView (    )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

Reimplemented in FinalHandle, FinalHandle< Map >, FinalHandle< coherence::util::List >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::lang::Object >, and FinalHandle< coherence::util::Map >.

operator ValueHandle (    )  [inline]

Return a Handle to the referenced Object.

Returns:
a Handle to the referenced Object

Reimplemented in FinalHandle, FinalHandle< Map >, FinalHandle< coherence::util::List >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::lang::Object >, and FinalHandle< coherence::util::Map >.

o (    )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

Reimplemented in FinalHandle, FinalHandle, FinalHandle< Map >, FinalHandle< Map >, FinalHandle< coherence::util::List >, FinalHandle< coherence::util::List >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::lang::Object >, FinalHandle< coherence::lang::Object >, FinalHandle< coherence::util::Map >, and FinalHandle< coherence::util::Map >.

o (    )  [inline]

Return a Handle to the referenced Object.

Returns:
a Handle to the referenced Object

Reimplemented in FinalHandle, FinalHandle, FinalHandle< Map >, FinalHandle< Map >, FinalHandle< coherence::util::List >, FinalHandle< coherence::util::List >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::lang::Object >, FinalHandle< coherence::lang::Object >, FinalHandle< coherence::util::Map >, and FinalHandle< coherence::util::Map >.

o (    )  const [inline]

Return a TypedHolder to the referenced Object.

Returns:
a TypedHolder to the referenced Object

Reimplemented in FinalHandle, FinalHandle, FinalHandle< Map >, FinalHandle< Map >, FinalHandle< coherence::util::List >, FinalHandle< coherence::util::List >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::lang::Object >, FinalHandle< coherence::lang::Object >, FinalHandle< coherence::util::Map >, and FinalHandle< coherence::util::Map >.

o (    )  [inline]

Return a TypedHolder to the referenced Object.

Returns:
a TypedHolder to the referenced Object

Reimplemented in FinalHandle, FinalHandle, FinalHandle< Map >, FinalHandle< Map >, FinalHandle< coherence::util::List >, FinalHandle< coherence::util::List >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::lang::Object >, FinalHandle< coherence::lang::Object >, FinalHandle< coherence::util::Map >, and FinalHandle< coherence::util::Map >.

ValueView operator-> (    )  const [inline]

Dereference the MemberHandle.

Returns:
a const pointer to the referenced Object

Reimplemented in FinalHandle, FinalHandle< Map >, FinalHandle< coherence::util::List >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::lang::Object >, and FinalHandle< coherence::util::Map >.

ValueHandle operator-> (    )  [inline]

Dereference the MemberHandle.

Returns:
a const pointer to the referenced Object

Reimplemented in FinalHandle, FinalHandle< Map >, FinalHandle< coherence::util::List >, FinalHandle< coherence::io::pof::WritingPofHandler >, FinalHandle< coherence::util::Iterator >, FinalHandle< coherence::util::ThreadGate >, FinalHandle< coherence::util::LongArray >, FinalHandle< coherence::lang::ThreadGroup >, FinalHandle< coherence::util::AtomicCounter >, FinalHandle< coherence::io::pof::WritingPofHandler::Complex >, FinalHandle< coherence::lang::ThreadLocalReference >, FinalHandle< coherence::io::WriteBuffer::BufferOutput >, FinalHandle< coherence::lang::Object >, and FinalHandle< coherence::util::Map >.

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

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

Set the MemberHandle to reference the same Object as the supplied Handle.

Parameters:
  that  the handle to copy
  pSync  optional external SyncornizedMemberBlock to use to avoid internal synchronization.

ValueView get ( SynchronizedMemberReadBlock pSync = NULL  )  const [inline, protected]

Return a View to the referenced Object.

Parameters:
  pSync  optional external SyncornizedMemberReadBlock to use to avoid internal synchronization.
Returns:
a View to the referenced Object

ValueHandle get ( SynchronizedMemberReadBlock pSync = NULL  )  [inline, protected]

Return a Handle to the referenced Object.

Parameters:
  pSync  optional external SyncornizedMemberReadBlock to use to avoid internal synchronization.
Returns:
a Handle to the referenced Object

virtual void onConst (    )  [inline, protected, virtual]

Event called when the guardian Object becomes only referenced via const pointers (Views).

As the SmartMember is a data-member of this Object, the data-member infer that only const methods will be called from now on.

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

Not that this method will only be called by the guardian if the SmartMember's mutability state is set to inherited.

The MemberHandle is automatically flipped when the guardian Object becomes only referenced via consts.

Reimplemented from SmartMember.


Friends And Related Function Documentation

D cast ( MemberHandle< T > &  mh,
    bool  fThrow = true  
  )     [friend]

Perform a dynamic cast the pointer associated with the MemberHandle to a the specified handle/view type.

Parameters:
  mh  the MemberHandle from which to perform the cast
  fThrow  true if an exception is to be thrown on a failed cast
Returns:
the casted pointer, or NULL if the cast fails and fThrow is false
Exceptions:
  ClassCastException  if the cast fails and fThrow is true

The documentation for this class was generated from the following file:

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