aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/common')
-rw-r--r--src/libjin/common/je_singleton.hpp16
-rw-r--r--src/libjin/common/je_subsystem.hpp12
2 files changed, 13 insertions, 15 deletions
diff --git a/src/libjin/common/je_singleton.hpp b/src/libjin/common/je_singleton.hpp
index ba13b80..51dc9c5 100644
--- a/src/libjin/common/je_singleton.hpp
+++ b/src/libjin/common/je_singleton.hpp
@@ -2,6 +2,7 @@
#define __JE_SINGLETON_H__
#include "je_object.h"
+#include "je_exception.h"
namespace JinEngine
{
@@ -38,7 +39,12 @@ namespace JinEngine
///
/// Singleton constructor.
///
- Singleton() {};
+ Singleton()
+ {
+ // Check singleton.
+ if (_instance)
+ throw Exception("This is a singleton.");
+ };
///
/// Singleton destructor.
@@ -70,12 +76,8 @@ namespace JinEngine
///
/// Singleton instance.
///
- template<class T> T* Singleton<T>::_instance = nullptr;
-
- ///
- /// Singleton notation.
- ///
- #define singleton(T) friend Singleton<T>
+ template<class T>
+ T* Singleton<T>::_instance = nullptr;
} // namespace JinEngine
diff --git a/src/libjin/common/je_subsystem.hpp b/src/libjin/common/je_subsystem.hpp
index c015bef..0119b74 100644
--- a/src/libjin/common/je_subsystem.hpp
+++ b/src/libjin/common/je_subsystem.hpp
@@ -32,7 +32,7 @@ namespace JinEngine
///
bool init(const SettingBase* setting = nullptr)
{
- static bool success = initSystem(setting);
+ static bool success = startSystem(setting);
return success;
}
@@ -46,9 +46,6 @@ namespace JinEngine
Singleton<System>::destroy();
}
- protected:
- singleton(System);
-
///
/// Subsystem constructor.
///
@@ -57,14 +54,13 @@ namespace JinEngine
///
/// Subsystem destructor.
///
- virtual ~Subsystem()
- {
- };
+ virtual ~Subsystem() {}
+ protected:
///
/// Initializer callback.
///
- virtual bool initSystem(const Setting* setting) = 0;
+ virtual bool startSystem(const Setting* setting) = 0;
///
/// Quit subsystem callback.