#include <coherence/lang/TypedHolder.hpp>
Inherited by SubscriptHolder.
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.
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) |
Perform the specified action. | |
Protected Attributes | |
const T * | m_cpo |
The referenced Object. |
TypedHolder | ( | const TypedHolder< T > & | that | ) | [inline] |
Construct a new TypedHolder referencing the same Object (and in the same manner) as the specified TypedHolder.
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.
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.
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.
po | pointer to the Object to reference |
TypedHolder | ( | DT * | po | ) | [inline] |
Construct a new TypedHolder referencing the supplied object.
po | pointer to the Object to reference |
TypedHolder& operator= | ( | const TypedHolder< T > & | that | ) | [inline] |
Assign this TypedHolder to reference the same Object (and in the same manner) as the specified TypedHolder.
that | the TypedHolder to assign from |
TypedHolder& operator= | ( | const TypedHolder< DT > & | that | ) | [inline] |
Assign this TypedHolder to reference the same Object (and in the same manner) as the specified TypedHolder.
that | the TypedHolder to assign from |
o | ( | ) | const [inline] |
const T& operator * | ( | ) | const [inline] |
Dereference this holder, returning T&
.
T&
reference to the referenced ObjectNullPointerException | if the this holder is NULL |
const T* operator-> | ( | ) | const [inline] |
bool isHandle | ( | ) | const [inline, protected] |
Return true if the holder contains a handle.
TypedHandle<T> getHandle | ( | ) | const [inline, protected] |
void set | ( | const T * | cp, | |
bool | fView, | |||
const ChainedHandleElement & | that | |||
) | [inline, protected] |
void performAction | ( | Action | nAction | ) | [inline, protected] |
Perform the specified action.
nAction | the action to perform |