MemberHandle Class Template Reference

#include <coherence/lang/MemberHandle.hpp>

Inherits SmartMember.

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 parent 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 permantently 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

enum  
 Flip states.
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 (Object &oParent)
 Construct a new MemberHandle referencing NULL via a handle.
template<class DH>
 MemberHandle (Object &oParent, const DH &h, bool fMutable=false)
 Construct a new MemberHandle referencing the specified Object via a handle.
 ~MemberHandle ()
 Destroy the MemberHandle.
MemberHandleoperator= (MemberHandle &that)
 Assign this MemberHandle to refrence the same Object as the specified MemberHandle.
template<class DT>
MemberHandleoperator= (const MemberHandle< DT > &mv)
 Assign this MemberHandle to refrence the same Object as the specified MemberHandle.
template<class DT>
MemberHandleoperator= (const TypedHolder< DT > &th)
 Assign this MemberHandle to refrence the same Object as the specified MemberHandle.
template<class DT>
MemberHandleoperator= (const MemberHolder< DT > &mh)
 Assign this MemberHandle to refrence the same Object as the specified MemberHolder.
template<class DT>
MemberHandleoperator= (const TypedHandle< DT > &h)
 Assign this MemberHandle to refrence the same Object (and in the same manner) as the specified MemberHandle.
MemberHandleoperator= (T *p)
 Assign this MemberHandle to refrence the same Object (and in the same manner) as the specified pointer.
 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 ()
ValueView operator-> () const
 Derefrence the MemberHandle.
ValueHandle operator-> ()
 Derefrence the MemberHandle.
template<class AT>
bool operator== (const MemberHandle< AT > &mv) const
 Compare the supplied MemberHandle to this MemberHandle.
template<class AT>
bool operator!= (const MemberHandle< AT > &mv) const
 Compare the supplied MemberHandle to this handle.
template<class AT>
bool operator== (const MemberHolder< AT > &mh) const
 Compare the supplied MemberHolder to this MemberHandle.
template<class AT>
bool operator!= (const MemberHolder< AT > &mh) const
 Compare the supplied MemberHolder to this MemberHandle.
template<class AT>
bool operator== (const MemberView< AT > &mv) const
 Compare the supplied MemberView to this MemberHandle.
template<class AT>
bool operator!= (const MemberView< AT > &mv) const
 Compare the supplied MemberView to this MemberHandle.
template<class AT>
bool operator== (const TypedHolder< AT > &th) const
 Compare the supplied holder to this handle.
template<class AT>
bool operator!= (const TypedHolder< AT > &th) const
 Compare the supplied holder to this handle.
template<class AT>
bool operator== (const TypedHandle< AT > &h) const
 Compare the supplied handle to this handle.
template<class AT>
bool operator!= (const TypedHandle< AT > &h) const
 Compare the supplied handle to this handle.
bool operator== (const Object *cpThat) const
 Compare the supplied pointer to this handle.
bool operator!= (const Object *cpThat) const
 Compare the supplied pointer to this handle.

Protected Member Functions

void set (const ValueHandle &h, 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.
void flipHandle ()
 Flip the MemberHandle from a Handle based to a View based reference.
virtual void onConst ()
 Event called when the parent 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.


Friends

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

Constructor & Destructor Documentation

MemberHandle ( Object oParent,
const DH &  h,
bool  fMutable = false 
) [inline]

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

Parameters:
oParent the Object to which this member belongs
h the handle to the Object to reference
fMutable true iff the member is declared mutable


Member Function Documentation

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

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

Parameters:
that the MemberHandle to assign from
Returns:
a reference to this MemberHandle

MemberHandle& operator= ( const MemberHandle< DT > &  mv  )  [inline]

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

Parameters:
mv the MemberHandle to assign from
Returns:
a reference to this MemberHandle

MemberHandle& operator= ( const TypedHolder< DT > &  th  )  [inline]

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

Parameters:
th the TypedHolder to assign from
Returns:
a reference to this MemberHandle

MemberHandle& operator= ( const MemberHolder< DT > &  mh  )  [inline]

Assign this MemberHandle to refrence the same Object as the specified MemberHolder.

Parameters:
mh the MemberHolder to assign from
Returns:
a reference to this MemberHandle

MemberHandle& operator= ( const TypedHandle< DT > &  h  )  [inline]

Assign this MemberHandle to refrence the same Object (and in the same manner) as the specified MemberHandle.

Parameters:
h the TypedHandle to assign from
Returns:
a reference to this MemberHandle

MemberHandle& operator= ( T *  p  )  [inline]

Assign this MemberHandle to refrence the same Object (and in the same manner) as the specified pointer.

Parameters:
p the pointer to assign from
Returns:
a reference to this MemberHandle

operator ValueView (  )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

operator ValueHandle (  )  [inline]

Return a Handle to the referenced Object.

Returns:
a Handle to the referenced Object

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 (  )  [inline]

Return a TypedHolder to the referenced Object.

Returns:
a TypedHolder to the referenced Object

ValueView operator-> (  )  const [inline]

Derefrence the MemberHandle.

Returns:
a const pointer to the referenced Object

ValueHandle operator-> (  )  [inline]

Derefrence the MemberHandle.

Returns:
a const pointer to the referenced Object

bool operator== ( const MemberHandle< AT > &  mv  )  const [inline]

Compare the supplied MemberHandle to this MemberHandle.

Parameters:
mv the MemberHandle to compare against
Returns:
true iff the same object is referenced

bool operator!= ( const MemberHandle< AT > &  mv  )  const [inline]

Compare the supplied MemberHandle to this handle.

Parameters:
mv the holder to compare against
Returns:
true iff different objects are referenced

bool operator== ( const MemberHolder< AT > &  mh  )  const [inline]

Compare the supplied MemberHolder to this MemberHandle.

Parameters:
mh the MemberHolder to compare against
Returns:
true iff the same object is referenced

bool operator!= ( const MemberHolder< AT > &  mh  )  const [inline]

Compare the supplied MemberHolder to this MemberHandle.

Parameters:
mh the holder to compare against
Returns:
true iff different objects are referenced

bool operator== ( const MemberView< AT > &  mv  )  const [inline]

Compare the supplied MemberView to this MemberHandle.

Parameters:
mv the MemberVeiw to compare against
Returns:
true iff the same object is referenced

bool operator!= ( const MemberView< AT > &  mv  )  const [inline]

Compare the supplied MemberView to this MemberHandle.

Parameters:
mv the view to compare against
Returns:
true iff different objects are referenced

bool operator== ( const TypedHolder< AT > &  th  )  const [inline]

Compare the supplied holder to this handle.

Parameters:
th the holder to compare against
Returns:
true iff the same object is referenced

bool operator!= ( const TypedHolder< AT > &  th  )  const [inline]

Compare the supplied holder to this handle.

Parameters:
th the holder to compare against
Returns:
true iff different objects are referenced

bool operator== ( const TypedHandle< AT > &  h  )  const [inline]

Compare the supplied handle to this handle.

Parameters:
h the handle to compare against
Returns:
true iff the same object is referenced

bool operator!= ( const TypedHandle< AT > &  h  )  const [inline]

Compare the supplied handle to this handle.

Parameters:
h the handle to compare against
Returns:
true iff the different objects are referenced

bool operator== ( const Object cpThat  )  const [inline]

Compare the supplied pointer to this handle.

Parameters:
cpThat the pointer to compare against
Returns:
true iff the same object is referenced

bool operator!= ( const Object cpThat  )  const [inline]

Compare the supplied pointer to this handle.

Parameters:
cpThat the pointer to compare against
Returns:
true iff different objects are referenced

void set ( const ValueHandle h,
SynchronizedMemberWriteBlock pSync = NULL 
) [inline, protected]

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

Parameters:
h 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

void flipHandle (  )  [inline, protected]

Flip the MemberHandle from a Handle based to a View based reference.

Once flipped the MemberHandle will no longer support changing the reference or returning a Handle to the referenced Object.

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

Event called when the parent 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.

The MemberHandle is automatically flipped when the parent Object bcomes only referenced via consts.

Reimplemented from SmartMember.


Friends And Related Function Documentation

D cast ( MemberHandle< T > &  mh,
bool  fTest = 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 (c) 2000-2008 Oracle. All rights reserved.