diff --git a/src/shared/Singleton.h b/src/shared/Singleton.h index 41f82300f754dae7330fa3b573f8fd9a19407a84..96d81c24f3abf91757c8fa9d3674db3e580acbed 100644 --- a/src/shared/Singleton.h +++ b/src/shared/Singleton.h @@ -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: - inline static T* getInstance() { - static T instance; - return &instance; - } - protected: - 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; }; diff --git a/src/shared/boards/AnakinBoard.h b/src/shared/boards/AnakinBoard.h index 87a24080af08e4ea06f38ecd0bb380549978c2ae..388f617b943a3524932395af0d3348f4723614d6 100644 --- a/src/shared/boards/AnakinBoard.h +++ b/src/shared/boards/AnakinBoard.h @@ -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