MemberHolder Class Template Reference

#include <coherence/lang/MemberHolder.hpp>

Inherits SmartMember.

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 convience handle type which can be used for container like classes, which need to be able to contain both Handles and Views.

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 TypedHolder< T > GetType
 Result type for a non-const get operation.

Public Member Functions

 MemberHolder (Object &oParent)
 Construct a new MemberHolder referencing NULL via a handle.
template<class DT>
 MemberHolder (Object &oParent, const TypedHandle< DT > &th)
 Construct a new MemberHolder refrencing specified Object via a Handle or View.
template<class DT>
 MemberHolder (Object &oParent, const TypedHolder< DT > &th)
 Construct a new MemberHolder refrencing the same Object (and in the same manner) as the specified TypedHolder.
template<class DT>
 MemberHolder (Object &oParent, const MemberHolder< DT > &that)
 Construct a new MemberHolder refrencing the same Object (and in the same manner) as the specified MemberHolder.
 ~MemberHolder ()
 Destroy the MemberHolder.
MemberHolderoperator= (const MemberHolder &that)
 Assign this MemberHolder to refrence the same Object (and in the same manner) as the specified MemberHolder.
template<class DT>
MemberHolderoperator= (const MemberHolder< DT > &mh)
 Assign this MemberHolder to refrence the same Object (and in the same manner) as the specified MemberHolder.
template<class DT>
MemberHolderoperator= (const TypedHolder< DT > &th)
 Assign this MemberHolder to refrence the same Object (and in the same manner) as the specified MemberHolder.
template<class DT>
MemberHolderoperator= (const TypedHandle< DT > &h)
 Assign this MemberHolder to refrence the same Object (and in the same manner) as the specified MemberHolder.
MemberHolderoperator= (const T *cp)
 Assign this MemberHolder to refrence the same Object (and in the same manner) as the specified pointer.
 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
 Derefrence the MemberHolder.
template<class AT>
bool operator== (const MemberHolder< AT > &mh) const
 Compare the supplied holder to this holder.
template<class AT>
bool operator!= (const MemberHolder< AT > &mh) const
 Compare the supplied holder to this holder.
template<class AT>
bool operator== (const TypedHolder< AT > &th) const
 Compare the supplied holder to this holder.
template<class AT>
bool operator!= (const TypedHolder< AT > &th) const
 Compare the supplied holder to this holder.
template<class AT>
bool operator== (const TypedHandle< AT > &h) const
 Compare the supplied handle to this holder.
template<class AT>
bool operator!= (const TypedHandle< AT > &h) const
 Compare the supplied handle to this holder.
bool operator== (const Object *cpThat) const
 Compare the supplied pointer to this holder.
bool operator!= (const Object *cpThat) const
 Compare the supplied pointer to this holder.

Protected Member Functions

 MemberHolder ()
 Construct a MemberHolder without any associated parent.
void setView (const TypedHandle< const T > &v, SynchronizedMemberWriteBlock *pSync=NULL)
 Set the Holder to reference an Object via a View.
void setHandle (const TypedHandle< T > &h, SynchronizedMemberWriteBlock *pSync=NULL)
 Set the Holder to reference an Object via a Handle.
template<class DT>
void set (const TypedHolder< DT > &th, SynchronizedMemberWriteBlock *pSync=NULL)
 Set the MemberHolder to reference the same Object as the specified TypedHolder.
TypedHolder< T > get (SynchronizedMemberReadBlock *pSync=NULL) const
 Return a TypedHolder referencing the same Object as this MemberHolder.

Constructor & Destructor Documentation

MemberHolder ( Object oParent,
const TypedHandle< DT > &  th 
) [inline]

Construct a new MemberHolder refrencing specified Object via a Handle or View.

As a Handle is used, the MemberHolder can be used with the cast() method to retrieve the Handle from the Holder.

Parameters:
oParent the self() on the object this data member is a member of
th a Handle or View to the Object to reference

MemberHolder ( Object oParent,
const TypedHolder< DT > &  th 
) [inline]

Construct a new MemberHolder refrencing the same Object (and in the same manner) as the specified TypedHolder.

Parameters:
oParent the self() on the object this data member is a member of
th the TypedHolder to initialize from

MemberHolder ( Object oParent,
const MemberHolder< DT > &  that 
) [inline]

Construct a new MemberHolder refrencing the same Object (and in the same manner) as the specified MemberHolder.

Parameters:
oParent the self() on the object this data member is a member of
that the MemberHolder to initialize from

MemberHolder (  )  [inline, protected]

Construct a MemberHolder without any associated parent.

The new MemberHolder is not useable until the parent is specified.


Member Function Documentation

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

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

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

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

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

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

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

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

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

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

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

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

MemberHolder& operator= ( const T *  cp  )  [inline]

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

Parameters:
cp the pointer to assign from
Returns:
a reference to this MemberHolder

operator ValueView (  )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

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]

Derefrence the MemberHolder.

Returns:
a const pointer to the referenced Object

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

Compare the supplied holder to this holder.

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

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

Compare the supplied holder to this holder.

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

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

Compare the supplied holder to this holder.

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 holder.

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 holder.

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 holder.

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 holder.

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 holder.

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

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

Set the Holder to reference an Object via a View.

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

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

Set the Holder to reference an Object via a Handle.

Parameters:
h the Handle to the Object to reference
pSync the sync block to delegate to or NULL to create one

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

Set the MemberHolder to reference the same Object as the specified TypedHolder.

Parameters:
th the TypedHolder to copy
pSync the sync 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 referecning the same Object as this MemberHolder


The documentation for this class was generated from the following file: Copyright (c) 2000-2008 Oracle. All rights reserved.