DtkCore
DTK Core module
dsingleton.h
1
// SPDX-FileCopyrightText: 2016 - 2022 UnionTech Software Technology Co., Ltd.
2
//
3
// SPDX-License-Identifier: LGPL-3.0-or-later
4
5
#ifndef DSINGLETON_H
6
#define DSINGLETON_H
7
8
#include "dtkcore_global.h"
9
10
DCORE_BEGIN_NAMESPACE
11
44
template
<
class
T>
45
class
LIBDTKCORESHARED_EXPORT
DSingleton
46
{
47
public
:
48
QT_DEPRECATED_X(
"Use ref"
)
49
static
inline
T *instance()
50
{
51
static
T *_instance =
new
T;
52
return
_instance;
53
}
54
55
static
T& ref()
56
{
57
static
T instance;
58
return
instance;
59
}
60
61
DSingleton
(T&&) =
delete
;
62
DSingleton
(
const
T&) =
delete
;
63
void
operator= (
const
T&) =
delete
;
64
65
protected
:
66
DSingleton
() =
default
;
67
virtual
~DSingleton
() =
default
;
68
};
69
70
DCORE_END_NAMESPACE
71
72
#endif
// DSINGLETON_H
Dtk::Core::DSingleton
Definition:
dsingleton.h:46
include
base
dsingleton.h
文档生成时间:2022-12-30-05:08 +00
Doxygen Version
1.9.4
制作者:deepin doc doc go SIG
文档使用CC-BY-4.0共享