X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fsingleton.hh;h=ec0d01e9997fbce426c4f41a460e00540f81c66f;hp=3b2ebf73239719f419f374e22527c24492f3b9e0;hb=7d15b919681bb9ec0088b4b27c6abf62d6dfb9b1;hpb=0fffd0097d7b496454413e57b398c903ecc252e4 diff --git a/src/singleton.hh b/src/singleton.hh index 3b2ebf7..ec0d01e 100644 --- a/src/singleton.hh +++ b/src/singleton.hh @@ -32,12 +32,21 @@ #include +namespace dc { + + template class singleton { static T* ptr_; public: + struct exception : public std::runtime_error + { + explicit exception(const std::string& what_arg) : + std::runtime_error(what_arg) {} + }; + singleton() { if (!ptr_) @@ -60,12 +69,12 @@ public: { if (!ptr_) { - throw std::runtime_error("accessing uninstantiated singleton"); + throw exception("accessing uninstantiated singleton"); } return *ptr_; } - static T* instance__ptr() + static T* instance_ptr() { return ptr_; } @@ -74,5 +83,9 @@ public: template T* singleton::ptr_ = 0; +} // namespace dc + #endif // _SINGLETON_HH_ +/** vim: set ts=4 sw=4 tw=80: *************************************************/ +