Skip to content
Snippets Groups Projects
Commit 69f6fb3b authored by Federico's avatar Federico
Browse files

Improved singleton

parent d6e77f04
Branches
Tags
No related merge requests found
......@@ -23,16 +23,33 @@
#ifndef SINGLETON_H
#define SINGLETON_H
/**
* WARNING: deriving from this class is not enough to make a singleton,
* you also have to declare the constructor of your class private!
*
* \code
* class Foo : public Singleton<Foo>
* {
* private:
* Foo() {} //Ok, private constructor
* };
* \endcode
*/
template<typename T>
class Singleton {
public:
/**
* \return a pointer to the only instance of the class T
*/
inline static T* getInstance() {
static T instance;
return &instance;
}
protected:
Singleton(){}
private:
Singleton(const Singleton&)=delete;
Singleton& operator=(const Singleton&)=delete;
};
......
......@@ -86,11 +86,6 @@ private:
ms580_t* mS_MS580;
AnakinBoard();
AnakinBoard(const AnakinBoard&) = delete;
AnakinBoard(AnakinBoard&&) = delete;
AnakinBoard& operator=(const AnakinBoard&) = delete;
AnakinBoard& operator=(AnakinBoard&&) = delete;
};
#ifdef sBoard
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment