QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | Protected Attributes | List of all members
Handle< T > Class Template Reference

Shared handle to an observable. More...

#include <handle.hpp>

+ Inheritance diagram for Handle< T >:
+ Collaboration diagram for Handle< T >:

Classes

class  Link
 

Public Member Functions

Constructors
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 to false when the passed shared pointer does not own the pointee (this 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.
 Handle ()
 
 Handle (const ext::shared_ptr< T > &p, bool registerAsObserver=true)
 
 Handle (ext::shared_ptr< T > &&p, bool registerAsObserver=true)
 
const ext::shared_ptr< T > & currentLink () const
 dereferencing More...
 
const ext::shared_ptr< T > & operator-> () const
 
const ext::shared_ptr< T > & operator* () const
 
bool empty () const
 checks if the contained shared pointer points to anything More...
 
 operator ext::shared_ptr< Observable > () const
 allows registration as observable More...
 
template<class U >
bool operator== (const Handle< U > &other) const
 equality test More...
 
template<class U >
bool operator!= (const Handle< U > &other) const
 disequality test More...
 
template<class U >
bool operator< (const Handle< U > &other) const
 strict weak ordering More...
 

Protected Attributes

ext::shared_ptr< Linklink_
 

Detailed Description

template<class T>
class QuantLib::Handle< T >

Shared handle to an observable.

All copies of an instance of this class refer to the same observable by means of a relinkable smart pointer. When such pointer is relinked to another observable, the change will be propagated to all the copies.

Precondition
Class T must inherit from Observable
Examples
BasketLosses.cpp, BermudanSwaption.cpp, Bonds.cpp, CDS.cpp, CVAIRS.cpp, CallableBonds.cpp, ConvertibleBonds.cpp, DiscreteHedging.cpp, EquityOption.cpp, FittedBondCurve.cpp, Gaussian1dModels.cpp, MulticurveBootstrapping.cpp, and Replication.cpp.

Definition at line 41 of file handle.hpp.

Constructor & Destructor Documentation

◆ Handle() [1/3]

Handle ( )

Definition at line 78 of file handle.hpp.

◆ Handle() [2/3]

Handle ( const ext::shared_ptr< T > &  p,
bool  registerAsObserver = true 
)
explicit

Definition at line 80 of file handle.hpp.

◆ Handle() [3/3]

Handle ( ext::shared_ptr< T > &&  p,
bool  registerAsObserver = true 
)
explicit

Definition at line 83 of file handle.hpp.

Member Function Documentation

◆ currentLink()

const ext::shared_ptr< T > & currentLink

dereferencing

Definition at line 173 of file handle.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator->()

const ext::shared_ptr< T > & operator->

Definition at line 179 of file handle.hpp.

+ Here is the call graph for this function:

◆ operator*()

const ext::shared_ptr< T > & operator*

Definition at line 185 of file handle.hpp.

+ Here is the call graph for this function:

◆ empty()

bool empty

checks if the contained shared pointer points to anything

Definition at line 191 of file handle.hpp.

+ Here is the caller graph for this function:

◆ operator ext::shared_ptr< Observable >()

operator ext::shared_ptr< Observable >

allows registration as observable

Definition at line 196 of file handle.hpp.

◆ operator==()

bool operator== ( const Handle< U > &  other) const

equality test

Definition at line 97 of file handle.hpp.

◆ operator!=()

bool operator!= ( const Handle< U > &  other) const

disequality test

Definition at line 100 of file handle.hpp.

◆ operator<()

bool operator< ( const Handle< U > &  other) const

strict weak ordering

Definition at line 103 of file handle.hpp.

Member Data Documentation

◆ link_

ext::shared_ptr<Link> link_
protected

Definition at line 59 of file handle.hpp.