summaryrefslogtreecommitdiffstats
path: root/src/leeds
diff options
context:
space:
mode:
Diffstat (limited to 'src/leeds')
-rw-r--r--src/leeds/CustomSoundTrack.cpp11
-rw-r--r--src/leeds/CustomSoundTrack.h20
-rw-r--r--src/leeds/base/singletonManager.cpp36
-rw-r--r--src/leeds/base/singletonManager.h60
4 files changed, 127 insertions, 0 deletions
diff --git a/src/leeds/CustomSoundTrack.cpp b/src/leeds/CustomSoundTrack.cpp
new file mode 100644
index 00000000..bcbfb82f
--- /dev/null
+++ b/src/leeds/CustomSoundTrack.cpp
@@ -0,0 +1,11 @@
+#include "common.h"
+
+#include "CustomSoundTrack.h"
+
+// TODO - implement
+
+cCustomSoundTrack* base::cSingleton<cCustomSoundTrack>::mspInstance = nil;
+
+cCustomSoundTrack::cCustomSoundTrack() :
+ m_bIsPlaying(false)
+{}
diff --git a/src/leeds/CustomSoundTrack.h b/src/leeds/CustomSoundTrack.h
new file mode 100644
index 00000000..e7b97fbc
--- /dev/null
+++ b/src/leeds/CustomSoundTrack.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "common.h"
+#include "singletonManager.h"
+
+class cCustomSoundTrack : public base::cSingleton<cCustomSoundTrack>
+{
+public:
+ bool m_bIsPlaying;
+
+ cCustomSoundTrack();
+ bool IsPlaying()
+ {
+#ifdef CUSTOM_SOUND_TRACK
+ return m_bIsPlaying;
+#else
+ return false;
+#endif
+ }
+}; \ No newline at end of file
diff --git a/src/leeds/base/singletonManager.cpp b/src/leeds/base/singletonManager.cpp
new file mode 100644
index 00000000..9ff9f28c
--- /dev/null
+++ b/src/leeds/base/singletonManager.cpp
@@ -0,0 +1,36 @@
+#include "common.h"
+
+#include "singletonManager.h"
+
+namespace base
+{
+
+cSingletonManager& SingletonManager()
+{
+ static cSingletonManager manager;
+ return manager;
+}
+
+cSingletonManager::~cSingletonManager()
+{
+ Purge();
+}
+
+void cSingletonManager::Add(cSingletonBase* node)
+{
+ node->next = head;
+ if (!head)
+ tail = node;
+ head = node;
+}
+
+void cSingletonManager::Purge()
+{
+ for (cSingletonBase* node = tail; node; node = tail) {
+ tail = node->next;
+ delete node;
+ }
+}
+
+
+} \ No newline at end of file
diff --git a/src/leeds/base/singletonManager.h b/src/leeds/base/singletonManager.h
new file mode 100644
index 00000000..833e178b
--- /dev/null
+++ b/src/leeds/base/singletonManager.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include "common.h"
+
+namespace base
+{
+
+class cSingletonBase
+{
+ friend class cSingletonManager;
+
+ cSingletonBase* next;
+
+public:
+ virtual ~cSingletonBase() {}
+};
+
+template<typename T>
+class cSingleton : public cSingletonBase
+{
+ static T* mspInstance;
+ static void cSingleton<T>::CreateInstance()
+ {
+ mspInstance = new T();
+ SingletonManager().Add(mspInstance);
+ }
+
+public:
+ static T* Instance()
+ {
+ if (!mspInstance)
+ CreateInstance();
+ return mspInstance;
+ }
+
+ ~cSingleton<T>()
+ {
+ mspInstance = nil;
+ }
+};
+
+class cSingletonManager
+{
+ cSingletonBase* head;
+ cSingletonBase* tail;
+
+public:
+ cSingletonManager() :
+ head(nil),
+ tail(nil)
+ {}
+
+ void Add(cSingletonBase*);
+ void Purge();
+ ~cSingletonManager();
+};
+
+cSingletonManager& SingletonManager();
+
+} \ No newline at end of file