summaryrefslogtreecommitdiffstats
path: root/src/leeds
diff options
context:
space:
mode:
Diffstat (limited to 'src/leeds')
-rw-r--r--src/leeds/CustomSoundTrack.cpp12
-rw-r--r--src/leeds/CustomSoundTrack.h20
-rw-r--r--src/leeds/base/singletonManager.cpp36
-rw-r--r--src/leeds/base/singletonManager.h62
4 files changed, 130 insertions, 0 deletions
diff --git a/src/leeds/CustomSoundTrack.cpp b/src/leeds/CustomSoundTrack.cpp
new file mode 100644
index 00000000..a71a66cc
--- /dev/null
+++ b/src/leeds/CustomSoundTrack.cpp
@@ -0,0 +1,12 @@
+#include "common.h"
+
+#include "CustomSoundTrack.h"
+
+// TODO - implement
+
+template<>
+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..9c980bb2
--- /dev/null
+++ b/src/leeds/base/singletonManager.h
@@ -0,0 +1,62 @@
+#pragma once
+
+#include "common.h"
+
+namespace base
+{
+
+class cSingletonBase;
+
+class cSingletonManager
+{
+ cSingletonBase* head;
+ cSingletonBase* tail;
+
+public:
+ cSingletonManager() :
+ head(nil),
+ tail(nil)
+ {}
+
+ void Add(cSingletonBase*);
+ void Purge();
+ ~cSingletonManager();
+};
+
+cSingletonManager& SingletonManager();
+
+class cSingletonBase
+{
+ friend class cSingletonManager;
+
+ cSingletonBase* next;
+
+public:
+ virtual ~cSingletonBase() {}
+};
+
+template<typename T>
+class cSingleton : public cSingletonBase
+{
+ static T* mspInstance;
+ static void CreateInstance()
+ {
+ mspInstance = new T();
+ SingletonManager().Add(mspInstance);
+ }
+
+public:
+ static T* Instance()
+ {
+ if (!mspInstance)
+ CreateInstance();
+ return mspInstance;
+ }
+
+ ~cSingleton<T>()
+ {
+ mspInstance = nil;
+ }
+};
+
+} \ No newline at end of file