Load GUI from XML
This commit is contained in:
24
Singleton.hh
Normal file
24
Singleton.hh
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef __OPENGLPLAYGROUND_SINGLETON_HH__
|
||||
#define __OPENGLPLAYGROUND_SINGLETON_HH__
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
template<typename T>
|
||||
class Singleton {
|
||||
public:
|
||||
static T& getInstance() {
|
||||
call_once(instance_flag, init);
|
||||
return *instance;
|
||||
}
|
||||
|
||||
private:
|
||||
static std::unique_ptr<T> instance;
|
||||
static std::once_flag instance_flag;
|
||||
|
||||
static void init() {
|
||||
instance.reset(new T{});
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user