#include <coherence/lang/MemberHandle.hpp>
Inherits SmartMember.
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.
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. | |
| MemberHandle & | operator= (MemberHandle &that) |
| Assign this MemberHandle to refrence the same Object as the specified MemberHandle. | |
| template<class DT> | |
| MemberHandle & | operator= (const MemberHandle< DT > &mv) |
| Assign this MemberHandle to refrence the same Object as the specified MemberHandle. | |
| template<class DT> | |
| MemberHandle & | operator= (const TypedHolder< DT > &th) |
| Assign this MemberHandle to refrence the same Object as the specified MemberHandle. | |
| template<class DT> | |
| MemberHandle & | operator= (const MemberHolder< DT > &mh) |
| Assign this MemberHandle to refrence the same Object as the specified MemberHolder. | |
| template<class DT> | |
| MemberHandle & | operator= (const TypedHandle< DT > &h) |
| Assign this MemberHandle to refrence the same Object (and in the same manner) as the specified MemberHandle. | |
| MemberHandle & | operator= (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> | |
| D | cast (MemberHandle< T > &mh, bool fTest) |
| Perform a dynamic cast the pointer associated with the MemberHandle to a the specified handle/view type. | |
| MemberHandle | ( | Object & | oParent, | |
| const DH & | h, | |||
| bool | fMutable = false | |||
| ) | [inline] |
Construct a new MemberHandle referencing the specified Object via a handle.
| MemberHandle& operator= | ( | MemberHandle< T > & | that | ) | [inline] |
Assign this MemberHandle to refrence the same Object as the specified MemberHandle.
| that | the MemberHandle to assign from |
| MemberHandle& operator= | ( | const MemberHandle< DT > & | mv | ) | [inline] |
Assign this MemberHandle to refrence the same Object as the specified MemberHandle.
| mv | the MemberHandle to assign from |
| MemberHandle& operator= | ( | const TypedHolder< DT > & | th | ) | [inline] |
Assign this MemberHandle to refrence the same Object as the specified MemberHandle.
| th | the TypedHolder to assign from |
| MemberHandle& operator= | ( | const MemberHolder< DT > & | mh | ) | [inline] |
Assign this MemberHandle to refrence the same Object as the specified MemberHolder.
| mh | the MemberHolder to assign from |
| MemberHandle& operator= | ( | const TypedHandle< DT > & | h | ) | [inline] |
Assign this MemberHandle to refrence the same Object (and in the same manner) as the specified MemberHandle.
| h | the TypedHandle to assign from |
| MemberHandle& operator= | ( | T * | p | ) | [inline] |
Assign this MemberHandle to refrence the same Object (and in the same manner) as the specified pointer.
| p | the pointer to assign from |
| operator ValueView | ( | ) | const [inline] |
| operator ValueHandle | ( | ) | [inline] |
| o | ( | ) | const [inline] |
| o | ( | ) | [inline] |
| ValueView operator-> | ( | ) | const [inline] |
| ValueHandle operator-> | ( | ) | [inline] |
| bool operator== | ( | const MemberHandle< AT > & | mv | ) | const [inline] |
Compare the supplied MemberHandle to this MemberHandle.
| mv | the MemberHandle to compare against |
| bool operator!= | ( | const MemberHandle< AT > & | mv | ) | const [inline] |
Compare the supplied MemberHandle to this handle.
| mv | the holder to compare against |
| bool operator== | ( | const MemberHolder< AT > & | mh | ) | const [inline] |
Compare the supplied MemberHolder to this MemberHandle.
| mh | the MemberHolder to compare against |
| bool operator!= | ( | const MemberHolder< AT > & | mh | ) | const [inline] |
Compare the supplied MemberHolder to this MemberHandle.
| mh | the holder to compare against |
| bool operator== | ( | const MemberView< AT > & | mv | ) | const [inline] |
Compare the supplied MemberView to this MemberHandle.
| mv | the MemberVeiw to compare against |
| bool operator!= | ( | const MemberView< AT > & | mv | ) | const [inline] |
Compare the supplied MemberView to this MemberHandle.
| mv | the view to compare against |
| bool operator== | ( | const TypedHolder< AT > & | th | ) | const [inline] |
Compare the supplied holder to this handle.
| th | the holder to compare against |
| bool operator!= | ( | const TypedHolder< AT > & | th | ) | const [inline] |
Compare the supplied holder to this handle.
| th | the holder to compare against |
| bool operator== | ( | const TypedHandle< AT > & | h | ) | const [inline] |
Compare the supplied handle to this handle.
| h | the handle to compare against |
| bool operator!= | ( | const TypedHandle< AT > & | h | ) | const [inline] |
Compare the supplied handle to this handle.
| h | the handle to compare against |
| bool operator== | ( | const Object * | cpThat | ) | const [inline] |
Compare the supplied pointer to this handle.
| cpThat | the pointer to compare against |
| bool operator!= | ( | const Object * | cpThat | ) | const [inline] |
Compare the supplied pointer to this handle.
| cpThat | the pointer to compare against |
| void set | ( | const ValueHandle & | h, | |
| SynchronizedMemberWriteBlock * | pSync = NULL | |||
| ) | [inline, protected] |
Set the MemberHandle to reference the same Object as the supplied Handle.
| h | the handle to copy | |
| pSync | optional external SyncornizedMemberBlock to use to avoid internal synchronization. |
| ValueView get | ( | SynchronizedMemberReadBlock * | pSync = NULL |
) | const [inline, protected] |
| ValueHandle get | ( | SynchronizedMemberReadBlock * | pSync = NULL |
) | [inline, protected] |
| 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.
| 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.
| mh | the MemberHandle from which to perform the cast | |
| fThrow | true if an exception is to be thrown on a failed cast |
| ClassCastException | if the cast fails and fThrow is true |