Oracle Coherence for C++ API
Release 3.6.1.0

E18813-01

TypedHolder Class Template Reference

#include <coherence/lang/TypedHolder.hpp>

Inherited by SubscriptHolder.

List of all members.


Detailed Description

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

A handle implementation which supports referencing Objects as either Handles or Views.

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

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

As with TypedHandles, TypedHolders are not thread-safe, and should not be used in a multi-threaded context even if protected by external synchronization. They should only be used as local variables. The most common place where thread-safe holders are needed is for object data members. For these cases the Coherence API includes a thread-safe variant MemberHolder.

Author:
mf 2008.01.09
See also:
MemberHolder

WeakHolder

FinalHolder


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.

Public Member Functions

  TypedHolder ()
  Construct a new TypedHolder referencing NULL via a handle.
  TypedHolder (const TypedHolder &that)
  Construct a new TypedHolder referencing the same Object (and in the same manner) as the specified TypedHolder.
template<class DT>
  TypedHolder (const TypedHandle< DT > &that)
  Construct a new TypedHolder referencing specified Object via a Handle or View.
template<class DT>
  TypedHolder (const TypedHolder< DT > &that)
  Construct a new TypedHolder referencing the same Object (and in the same manner) as the specified TypedHolder.
  TypedHolder (T *po)
  Construct a new TypedHolder referencing the supplied object.
template<class DT>
  TypedHolder (DT *po)
  Construct a new TypedHolder referencing the supplied object.
  ~TypedHolder ()
  Destroy the TypedHolder.
TypedHolder operator= (const TypedHolder &that)
  Assign this TypedHolder to reference the same Object (and in the same manner) as the specified TypedHolder.
template<class DT>
TypedHolder operator= (const TypedHolder< DT > &that)
  Assign this TypedHolder to reference the same Object (and in the same manner) as the specified TypedHolder.
template<class PT>
  o () const
  Return a View to the referenced Object.
const T &  operator * () const
  Dereference this holder, returning T&.
const T *  operator-> () const
  Dereference the TypedHolder.

Protected Member Functions

bool  isHandle () const
  Return true if the holder contains a handle.
TypedHandle< T >  getHandle () const
  Return a Handle to the referenced Object.
void  set (const T *cp, bool fView, const ChainedHandleElement &that)
  Set the Holder to reference an Object via a Handle.
void  performAction (Action nAction, const T *cpo, bool fView)
  Perform the specified action.
void  safeDestruct (Action nAction)
  Destruct the handle.

Protected Attributes

const T *  m_cpo
  The referenced Object.

Constructor & Destructor Documentation

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

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

Parameters:
that  the TypedHolder to initialize from

TypedHolder ( const TypedHandle< DT > &  that  )  [inline]

Construct a new TypedHolder referencing specified Object via a Handle or View.

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

Parameters:
that  a Handle or View to the Object to reference

TypedHolder ( const TypedHolder< DT > &  that  )  [inline]

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

Parameters:
that  the TypedHolder to initialize from

TypedHolder ( T *  po  )  [inline]

Construct a new TypedHolder referencing the supplied object.

This method is primarily intended to support assignment from NULL, though it will work with other pointers.

Parameters:
po  pointer to the Object to reference

TypedHolder ( DT *  po  )  [inline]

Construct a new TypedHolder referencing the supplied object.

Parameters:
po  pointer to the Object to reference

Member Function Documentation

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

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

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

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

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

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

o (  )  const [inline]

Return a View to the referenced Object.

Returns:
a View to the referenced Object

const T& operator * (  )  const [inline]

Dereference this holder, returning T&.

Returns:
a raw T& reference to the referenced Object
Exceptions:
NullPointerException  if the this holder is NULL

const T* operator-> (  )  const [inline]

Dereference the TypedHolder.

Returns:
a const pointer to the referenced Object

bool isHandle (  )  const [inline, protected]

Return true if the holder contains a handle.

Returns:
true iff the holder contains a handle

TypedHandle<T> getHandle (  )  const [inline, protected]

Return a Handle to the referenced Object.

Returns:
a Handle to the referenced Object, or NULL if the Object is referenced via a View

void set ( const T *  cp,
bool  fView,
const ChainedHandleElement &  that  
) [inline, protected]

Set the Holder to reference an Object via a Handle.

Parameters:
h  the Handle to the Object to reference

void performAction ( Action  nAction,
const T *  cpo,
bool  fView  
) [inline, protected]

Perform the specified action.

Parameters:
nAction  the action to perform
po  pointer to object on which to act
fView  if po references a view

void safeDestruct ( Action  nAction  )  [inline, protected]

Destruct the handle.

Any exception occurring during distribution will simply be printed, the intent of this function is for use during TypedHandle destruction. It is not the common path and is pulled out to encourage inlining of the destructor.


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