singleton.h
#ifndef SINGLETON_H
#define SINGLETON_H
template <typename T>
class Singleton
{public:static T& GetInstance(){
static T instance;
return instance;
}private:Singleton() = default;
~Singleton() = default;
Singleton(const Singleton&) = delete;
Singleton& operator=(const Singleton&) = delete;
Singleton(Singleton&&) = delete;
Singleton& operator=(Singleton&&) = delete;
};
#endif // SINGLETON_H
How to use?Singleton<LogManager>::GetInstance()
.info(this->metaObject()->className(),
Q_FUNC_INFO, "Initialized",
false,
false);info is my method...
Yorumlar
Yorum Gönder