]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Singleton.hh
extreme refactoring
[chaz/yoink] / src / Moof / Singleton.hh
similarity index 80%
rename from src/singleton.hh
rename to src/Moof/Singleton.hh
index ec0d01e9997fbce426c4f41a460e00540f81c66f..3d60ff29bc92b05535d56d1a8cd195d9153f24be 100644 (file)
 
 *******************************************************************************/
 
-#ifndef _SINGLETON_HH_
-#define _SINGLETON_HH_
+#ifndef _MOOF_SINGLETON_HH_
+#define _MOOF_SINGLETON_HH_
 
 #include <stdexcept>
 
 
-namespace dc {
+namespace Mf {
 
 
 template <typename T>
-class singleton
+class Singleton
 {
        static T* ptr_;
 
 public:
-       struct exception : public std::runtime_error
+       struct Exception : public std::runtime_error
        {
-               explicit exception(const std::string& what_arg) :
+               explicit Exception(const std::string& what_arg) :
                        std::runtime_error(what_arg) {}
        };
 
-       singleton()
+       Singleton()
        {
                if (!ptr_)
                {
                        // This hack is from Game Programming Gems.
-                       long long offset = (long long)(T*)1 - (long long)(singleton<T>*)(T*)1;
+                       long long offset = (long long)(T*)1 - (long long)(Singleton<T>*)(T*)1;
                        ptr_ = (T*)((long long)this + offset);
                }
        }
-       ~singleton()
+       ~Singleton()
        {
-               long long offset = (long long)(T*)1 - (long long)(singleton<T>*)(T*)1;
+               long long offset = (long long)(T*)1 - (long long)(Singleton<T>*)(T*)1;
                if (ptr_ == (T*)((long long)this + offset))
                {
                        ptr_ = 0;
@@ -69,7 +69,7 @@ public:
        {
                if (!ptr_)
                {
-                       throw exception("accessing uninstantiated singleton");
+                       throw Exception("accessing uninstantiated singleton");
                }
                return *ptr_;
        }
@@ -80,12 +80,12 @@ public:
        }
 };
 
-template <typename T> T* singleton<T>::ptr_ = 0;
+template <typename T> T* Singleton<T>::ptr_ = 0;
 
 
-} // namespace dc
+} // namespace Mf
 
-#endif // _SINGLETON_HH_
+#endif // _MOOF_SINGLETON_HH_
 
 /** vim: set ts=4 sw=4 tw=80: *************************************************/
 
This page took 0.019592 seconds and 4 git commands to generate.