diff options
Diffstat (limited to 'src/qdoc/qdoc/src/qdoc/singleton.h')
-rw-r--r-- | src/qdoc/qdoc/src/qdoc/singleton.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/qdoc/qdoc/src/qdoc/singleton.h b/src/qdoc/qdoc/src/qdoc/singleton.h new file mode 100644 index 000000000..085a5ea64 --- /dev/null +++ b/src/qdoc/qdoc/src/qdoc/singleton.h @@ -0,0 +1,32 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#ifndef SINGLETON_H +#define SINGLETON_H + +QT_BEGIN_NAMESPACE + +/*! + \class Singleton + \internal + + Class template for singleton objects in QDoc. + */ +template<typename T> +class Singleton +{ +public: + Singleton(const Singleton &) = delete; + Singleton &operator=(const Singleton &) = delete; + static T &instance() + { + static T s_instance {}; + return s_instance; + } + +protected: + Singleton() = default; +}; + +QT_END_NAMESPACE + +#endif // SINGLETON_H |