QuantLib
A free/open-source library for quantitative finance
Fully annotated sources - version 1.22
Static Public Member Functions | Protected Member Functions | List of all members
Singleton< T > Class Template Reference

Basic support for the singleton pattern. More...

#include <ql/patterns/singleton.hpp>

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

Static Public Member Functions

static Tinstance ()
 access to the unique instance More...
 

Protected Member Functions

 Singleton ()=default
 

Detailed Description

template<class T>
class QuantLib::Singleton< T >

Basic support for the singleton pattern.

The typical use of this class is:

class Foo : public Singleton<Foo> {
friend class Singleton<Foo>;
private:
Foo() {}
public:
...
};

which, albeit sub-optimal, frees one from the concerns of creating and managing the unique instance and can serve later as a single implemementation point should synchronization features be added.

Definition at line 126 of file singleton.hpp.

Constructor & Destructor Documentation

◆ Singleton()

Singleton ( )
protecteddefault

Member Function Documentation

◆ instance()

T & instance
static

access to the unique instance

Examples
BermudanSwaption.cpp, Bonds.cpp, ConvertibleBonds.cpp, EquityOption.cpp, Gaussian1dModels.cpp, MulticurveBootstrapping.cpp, and Replication.cpp.

Definition at line 160 of file singleton.hpp.

+ Here is the caller graph for this function:
QuantLib::Singleton::Singleton
Singleton()=default