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
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class Singleton
10 \internal
11
12 Class template for singleton objects in QDoc.
13 */
14template<typename T>
15class Singleton
16{
17public:
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
26protected:
27 Singleton() = default;
28};
29
30QT_END_NAMESPACE
31
32#endif // SINGLETON_H
33

source code of qttools/src/qdoc/qdoc/singleton.h