1 | // Copyright (C) 2020 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | #ifndef SINGLETON_H |
4 | #define SINGLETON_H |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | /*! |
9 | \class Singleton |
10 | \internal |
11 | |
12 | Class template for singleton objects in QDoc. |
13 | */ |
14 | template<typename T> |
15 | class Singleton |
16 | { |
17 | public: |
18 | Singleton(const Singleton &) = delete; |
19 | Singleton &operator=(const Singleton &) = delete; |
20 | static T &instance() |
21 | { |
22 | static T s_instance {}; |
23 | return s_instance; |
24 | } |
25 | |
26 | protected: |
27 | Singleton() = default; |
28 | }; |
29 | |
30 | QT_END_NAMESPACE |
31 | |
32 | #endif // SINGLETON_H |
33 | |