BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ISingleton.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/mainwindow/ISingleton.h
6 //! @brief Defines the standard mix-in ISingleton.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_COREGUI_MAINWINDOW_ISINGLETON_H
16 #define BORNAGAIN_GUI_COREGUI_MAINWINDOW_ISINGLETON_H
17 
18 //! Base class for singletons.
19 //! @ingroup tools_internal
20 
21 template <class T> class ISingleton {
22 public:
23  static T& instance()
24  {
25  static T m_instance;
26  return m_instance;
27  }
28 
29 protected:
30  ISingleton() = default;
31  ~ISingleton() = default;
32 
33 private:
34  ISingleton(const ISingleton&) = delete;
35  ISingleton& operator=(const ISingleton&) = delete;
36  ISingleton(ISingleton&&) = delete;
38 };
39 
40 #endif // BORNAGAIN_GUI_COREGUI_MAINWINDOW_ISINGLETON_H
Base class for singletons.
Definition: ISingleton.h:21
ISingleton & operator=(const ISingleton &)=delete
ISingleton()=default
ISingleton(ISingleton &&)=delete
static T & instance()
Definition: ISingleton.h:23
ISingleton & operator=(ISingleton &&)=delete
ISingleton(const ISingleton &)=delete
~ISingleton()=default