aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/common/singleton.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/common/singleton.hpp')
-rw-r--r--src/libjin/common/singleton.hpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/src/libjin/common/singleton.hpp b/src/libjin/common/singleton.hpp
index 015c9b0..f66d6e6 100644
--- a/src/libjin/common/singleton.hpp
+++ b/src/libjin/common/singleton.hpp
@@ -7,77 +7,77 @@
namespace JinEngine
{
- ///
- /// Singleton base class.
- ///
- template<class T>
- class Singleton : public Object
- {
- public:
- ///
- /// Get singleton.
- ///
- /// @param Singleton instance of class.
- ///
- static T* get()
- {
- if (_instance == nullptr)
- _instance = new T;
- return _instance;
- }
+ ///
+ /// Singleton base class.
+ ///
+ template<class T>
+ class Singleton : public Object
+ {
+ public:
+ ///
+ /// Get singleton.
+ ///
+ /// @param Singleton instance of class.
+ ///
+ static T* get()
+ {
+ if (_instance == nullptr)
+ _instance = new T;
+ return _instance;
+ }
- ///
- /// Destroy instance of singleton.
- ///
- static void destroy()
- {
- delete _instance;
- _instance = nullptr;
- }
+ ///
+ /// Destroy instance of singleton.
+ ///
+ static void destroy()
+ {
+ delete _instance;
+ _instance = nullptr;
+ }
- protected:
- ///
- /// Singleton constructor.
- ///
- Singleton()
- {
- // Check singleton.
- if (_instance)
- throw Exception("This is a singleton.");
- };
+ protected:
+ ///
+ /// Singleton constructor.
+ ///
+ Singleton()
+ {
+ // Check singleton.
+ if (_instance)
+ throw Exception("This is a singleton.");
+ };
- ///
- /// Singleton destructor.
- ///
- virtual ~Singleton() {};
+ ///
+ /// Singleton destructor.
+ ///
+ virtual ~Singleton() {};
- ///
- /// Singleton instance.
- ///
- static T* _instance;
+ ///
+ /// Singleton instance.
+ ///
+ static T* _instance;
- private:
- ///
- /// Singleton copy constructor.
- ///
- /// @param singleton Singleton of class.
- ///
- Singleton(const Singleton& singleton);
+ private:
+ ///
+ /// Singleton copy constructor.
+ ///
+ /// @param singleton Singleton of class.
+ ///
+ Singleton(const Singleton& singleton);
- ///
- /// Singleton assignment.
- ///
- /// @param singleton Singleton of class.
- ///
- Singleton& operator = (const Singleton& singleton);
+ ///
+ /// Singleton assignment.
+ ///
+ /// @param singleton Singleton of class.
+ ///
+ Singleton& operator = (const Singleton& singleton);
- };
+ };
- ///
- /// Singleton instance.
- ///
- template<class T>
- T* Singleton<T>::_instance = nullptr;
+ ///
+ /// Singleton instance.
+ ///
+ template<class T>
+ T* Singleton<T>::_instance = nullptr;
} // namespace JinEngine