QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
|
Basic support for the singleton pattern. More...
#include <singleton.hpp>
Public Member Functions | |
Singleton (const Singleton &)=delete | |
Singleton (Singleton &&)=delete | |
Singleton & | operator= (const Singleton &)=delete |
Singleton & | operator= (Singleton &&)=delete |
~Singleton ()=default | |
Static Public Member Functions | |
static T & | instance () |
access to the unique instance More... | |
Protected Member Functions | |
Singleton ()=default | |
Basic support for the singleton pattern.
The typical use of this class is:
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.
Global can be used to distinguish Singletons that are local to a session (Global = false) or that are global across all sessions (B = true). This is only relevant if QL_ENABLE_SESSIONS is enabled.
Notice that the creation and retrieval of (local or global) singleton instances through instance() is thread safe, but obviously subsequent operations on the singleton have to be synchronized within the singleton implementation itself.
Definition at line 58 of file singleton.hpp.
|
default |
|
protecteddefault |
|
static |
access to the unique instance
Definition at line 104 of file singleton.hpp.