aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/EventRecorder.cpp2
-rw-r--r--common/archive.cpp5
-rw-r--r--common/config-manager.cpp2
-rw-r--r--common/singleton.h13
4 files changed, 17 insertions, 5 deletions
diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp
index 47ab3da3d6..92cef51cf4 100644
--- a/common/EventRecorder.cpp
+++ b/common/EventRecorder.cpp
@@ -27,7 +27,7 @@
#include "common/config-manager.h"
-DECLARE_SINGLETON(Common::EventRecorder);
+DECLARE_SINGLETON(Common::EventRecorder)
namespace Common {
diff --git a/common/archive.cpp b/common/archive.cpp
index f0790f1a27..fe62355b8a 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -270,8 +270,6 @@ SeekableReadStream *SearchSet::createReadStreamForMember(const String &name) con
}
-DECLARE_SINGLETON(SearchManager);
-
SearchManager::SearchManager() {
clear(); // Force a reset
}
@@ -291,3 +289,6 @@ void SearchManager::clear() {
}
} // namespace Common
+
+DECLARE_SINGLETON(Common::SearchManager)
+
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index 5934f32012..9d8281a748 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -29,7 +29,7 @@
#include "common/util.h"
#include "common/system.h"
-DECLARE_SINGLETON(Common::ConfigManager);
+DECLARE_SINGLETON(Common::ConfigManager)
static bool isValidDomainName(const Common::String &domName) {
const char *p = domName.c_str();
diff --git a/common/singleton.h b/common/singleton.h
index 1a7b339bf6..d66fb84cc2 100644
--- a/common/singleton.h
+++ b/common/singleton.h
@@ -91,7 +91,18 @@ protected:
typedef T SingletonBaseType;
};
-#define DECLARE_SINGLETON(T) template<> T *Common::Singleton<T>::_singleton = 0
+/**
+ * Note that you need to use this macro from the global namespace.
+ *
+ * This is because C++ requires initial explicit specialization
+ * to be placed in the same namespace as the template.
+ * It has to be put in the global namespace to assure the correct
+ * namespace Common is referenced.
+ */
+#define DECLARE_SINGLETON(T) \
+ namespace Common { \
+ template<> T *Singleton<T>::_singleton = 0; \
+ } // End of namespace Common
} // End of namespace Common