#include <coherence/lang/FinalHandle.hpp>
Inherits MemberHandle< T >.
FinalHandles may either be initialized with a value at construction-time, or thereafter via the initialize() function. A FinalHandle may be initialized only if the following conditions hold:
initialize()
)
class Foo : public class_spec<Foo> { friend class factory<Foo>; protected: Foo() : m_fhBar(self()) // construction without initialization {} public: void setBar(Bar::Handle hBar) { initialize(m_fhBar, hBar); // post-construction initialization } private: FinalHandle<Bar> m_fhBar; };
FinalHandles transfer the constness of their parent Object. When a FinalHandle 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 FinalHandle will also automatically, and permanently switch its reference type from a handle to a view.
Note: In the rare case that a FinalHandle is declared via the mutable keyword, the FinalHandle must be informed of this fact by setting fMutable to true during construction. A mutable FinalHandle will will return Handles from const methods of the class it is a data member of. The FinalHandle cannot be reassigned to reference another object.
Public Types | |
typedef 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 | |
FinalHandle (const Object &oGuardian) | |
Construct a new FinalHandle referencing NULL via a handle. | |
FinalHandle (const Object &oGuardian, const ValueHandle &that) | |
Construct a new FinalHandle referencing specified Object. | |
FinalHandle (const Object &oGuardian, const ValueHandle &that, bool fMutable) | |
Construct a new FinalHandle referencing specified Object. | |
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 () const | |
Return a TypedHolder to the referenced Object. | |
template<class PT> | |
o () | |
Return a TypedHolder to the referenced Object. | |
const T * | operator-> () const |
Dereference the FinalHandle. | |
T * | operator-> () |
Dereference the FinalHandle. | |
Protected Member Functions | |
void | initialize (ValueHandle that) |
Initialize the value of a FinalHandle after it is constructed. |
FinalHandle | ( | const Object & | oGuardian | ) | [inline] |
Construct a new FinalHandle referencing NULL via a handle.
oGuardian | the object that protects this member |
FinalHandle | ( | const Object & | oGuardian, | |
const ValueHandle & | that | |||
) | [inline] |
Construct a new FinalHandle referencing specified Object.
oGuardian | the object that protects this member | |
that | the object to reference |
FinalHandle | ( | const Object & | oGuardian, | |
const ValueHandle & | that, | |||
bool | fMutable | |||
) | [inline] |
Construct a new FinalHandle referencing specified Object.
oGuardian | the object that protects this member | |
that | the object to reference | |
fMutable | true if the member is declared as mutable, false if declared as const |
operator ValueView | ( | ) | const [inline] |
Return a View to the referenced Object.
Reimplemented from MemberHandle.
operator ValueHandle | ( | ) | [inline] |
Return a Handle to the referenced Object.
Reimplemented from MemberHandle.
o | ( | ) | const [inline] |
Return a View to the referenced Object.
Reimplemented from MemberHandle.
o | ( | ) | [inline] |
Return a Handle to the referenced Object.
Reimplemented from MemberHandle.
o | ( | ) | const [inline] |
Return a TypedHolder to the referenced Object.
Reimplemented from MemberHandle.
o | ( | ) | [inline] |
Return a TypedHolder to the referenced Object.
Reimplemented from MemberHandle.
const T* operator-> | ( | ) | const [inline] |
Dereference the FinalHandle.
Reimplemented from MemberHandle.
T* operator-> | ( | ) | [inline] |
Dereference the FinalHandle.
Reimplemented from MemberHandle.
void initialize | ( | ValueHandle | that | ) | [inline, protected] |
Initialize the value of a FinalHandle after it is constructed.
A FinalHandle may be initialized only if the following conditions hold:
initialize()
)
that | the value to initialize this FinalHandle to |