DtkCore
DTK Core module
载入中...
搜索中...
未找到
Dtk::Core::DSingleton< T > 模板类 参考

#include <dsingleton.h>

Public 成员函数

 DSingleton (T &&)=delete
 
 DSingleton (const T &)=delete
 
void operator= (const T &)=delete
 

静态 Public 成员函数

static T & ref ()
 

详细描述

template<class T>
class Dtk::Core::DSingleton< T >

a simple singleton template for std c++ 11 or later.

example:

class ExampleSingleton : public QObject, public Dtk::DSingleton<ExampleSingleton>
{
Q_OBJECT
friend class DSingleton<ExampleSingleton>;
};
Definition dsingleton.h:46
注解
: for Qt, "public DSingleton<ExampleSingleton>" must be after QObject.

通过c++11的特性实现的单例模板

使用示例:

class ExampleSingleton : public QObject, public Dtk::DSingleton<ExampleSingleton>
{
Q_OBJECT
friend class DSingleton<ExampleSingleton>;
};
注解
对于Qt程序 public DSingleton<ExampleSingleton>" 必须在卸载QObject后面出现。

该类的文档由以下文件生成: