#include <coherence/lang/TypedHolder.hpp>
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 convience handle type which can be used for container like classes, which need to be able to contain both Handles and Views.
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 refrencing the same Object (and in the same manner) as the specified TypedHolder. | |
| template<class DT> | |
| TypedHolder (const TypedHandle< DT > &th) | |
| Construct a new TypedHolder refrencing specified Object via a Handle or View. | |
| template<class DT> | |
| TypedHolder (const TypedHolder< DT > &that) | |
| Construct a new TypedHolder refrencing the same Object (and in the same manner) as the specified TypedHolder. | |
| TypedHolder (T *p) | |
| Construct a new TypedHolder refrencing the supplied object. | |
| ~TypedHolder () | |
| Destroy the TypedHolder. | |
| TypedHolder & | operator= (const TypedHolder &that) |
| Assign this TypedHolder to refrence 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 refrence the same Object (and in the same manner) as the specified TypedHolder. | |
| template<class PT> | |
| o () const | |
| Return a View to the referenced Object. | |
| T & | operator * () const |
Dereference this holder, returning T&. | |
| const T * | operator-> () const |
| Derefrence the TypedHolder. | |
| template<class AT> | |
| bool | operator== (const TypedHolder< AT > &h) const |
| Compare the supplied holder to this holder. | |
| template<class AT> | |
| bool | operator!= (const TypedHolder< AT > &h) 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 *cpo) const |
| Compare the supplied pointer to this holder. | |
| bool | operator!= (const Object *cpo) const |
| Compare the supplied pointer to this holder. | |
Protected Member Functions | |
| ValueView | getView () const |
| Return a View to the referenced Object. | |
| ValueHandle | getHandle () const |
| Return a Handle to the referenced Object. | |
| void | setView (const ValueView &v) |
| Set the Holder to reference an Object via a View. | |
| void | setHandle (const ValueHandle &h) |
| Set the Holder to reference an Object via a Handle. | |
| TypedHolder | ( | const TypedHolder< T > & | that | ) | [inline] |
Construct a new TypedHolder refrencing the same Object (and in the same manner) as the specified TypedHolder.
| that | the TypedHolder to initialize from |
| TypedHolder | ( | const TypedHandle< DT > & | th | ) | [inline] |
Construct a new TypedHolder refrencing 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.
| th | a Handle or View to the Object to reference |
| TypedHolder | ( | const TypedHolder< DT > & | that | ) | [inline] |
Construct a new TypedHolder refrencing the same Object (and in the same manner) as the specified TypedHolder.
| that | the TypedHolder to initialize from |
| TypedHolder | ( | T * | p | ) | [inline] |
Construct a new TypedHolder refrencing the supplied object.
This method is primarily intended to support assignment from NULL, though it will work with other non-const pointers. To avoid introducing ambiguity in the case of NULL, there is no corresponding const T* variant. In the rare cases where one is needed the supplied const pointer should be externally wrapped in a View.
| p | pointer to the Object to reference |
| TypedHolder& operator= | ( | const TypedHolder< T > & | that | ) | [inline] |
Assign this TypedHolder to refrence 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 refrence the same Object (and in the same manner) as the specified TypedHolder.
| that | the TypedHolder to assign from |
| o | ( | ) | const [inline] |
| T& operator * | ( | ) | const [inline] |
Dereference this holder, returning T&.
T& reference to the refernced Object| NullPointerException | if the this holder is NULL |
| const T* operator-> | ( | ) | const [inline] |
| bool operator== | ( | const TypedHolder< AT > & | h | ) | const [inline] |
Compare the supplied holder to this holder.
| h | the holder to compare against |
| bool operator!= | ( | const TypedHolder< AT > & | h | ) | const [inline] |
Compare the supplied holder to this holder.
| h | the holder to compare against |
| bool operator== | ( | const TypedHandle< AT > & | h | ) | const [inline] |
Compare the supplied handle to this holder.
| h | the handle to compare against |
| bool operator!= | ( | const TypedHandle< AT > & | h | ) | const [inline] |
Compare the supplied handle to this holder.
| h | the handle to compare against |
| bool operator== | ( | const Object * | cpo | ) | const [inline] |
Compare the supplied pointer to this holder.
| cpo | the pointer to compare against |
| bool operator!= | ( | const Object * | cpo | ) | const [inline] |
Compare the supplied pointer to this holder.
| cpo | the pointer to compare against |
| ValueView getView | ( | ) | const [inline, protected] |
| ValueHandle getHandle | ( | ) | const [inline, protected] |
| void setView | ( | const ValueView & | v | ) | [inline, protected] |
| void setHandle | ( | const ValueHandle & | h | ) | [inline, protected] |