Link Class Template Reference
#include <ql/handle.hpp>
Inheritance diagram for Link:

Detailed Description
template<class T>
class QuantLib::Link< T >
Relinkable access to a shared pointer.
- Precondition:
- Class T must inherit from Observable
Public Member Functions | |
Link (const boost::shared_ptr< T > &h=boost::shared_ptr< T >(), bool registerAsObserver=true) | |
void | linkTo (const boost::shared_ptr< T > &, bool registerAsObserver=true) |
bool | empty () const |
Checks if the contained shared pointer points to anything. | |
const boost::shared_ptr< T > & | currentLink () const |
Returns the contained shared pointer. | |
void | swap (Link< T > &other) |
Swaps two links. | |
void | update () |
Observer interface. | |
Related Functions | |
(Note that these are not member functions.) | |
void | swap (Link< T > &, Link< T > &) |
Constructor & Destructor Documentation
Link | ( | const boost::shared_ptr< T > & | h = boost::shared_ptr< T >() , |
|
bool | registerAsObserver = true | |||
) | [explicit] |
Member Function Documentation
void linkTo | ( | const boost::shared_ptr< T > & | , | |
bool | registerAsObserver = true | |||
) |
- Warning:
registerAsObserver
is left as a backdoor in case the programmer cannot guarantee that the object pointed to will remain alive for the whole lifetime of the handle---namely, it should be set tofalse
when the passed shared pointer was created withowns = false
(the latter should only happen in a controlled environment, so that the programmer is aware of it). Failure to do so can very likely result in a program crash. If the programmer does want the handle to register as observer of such a shared pointer, it is his responsibility to ensure that the handle gets destroyed before the pointed object does.