diff options
Diffstat (limited to 'src/Singleton.hpp')
-rwxr-xr-x | src/Singleton.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Singleton.hpp b/src/Singleton.hpp index 2bdf257..4b7e2b4 100755 --- a/src/Singleton.hpp +++ b/src/Singleton.hpp @@ -7,6 +7,13 @@ #include <cstdlib> #include <stdexcept> +#define DECLARE_SINGLETON( T ) \ + friend class scopedPtr< T >; \ + friend class Singleton< T >; + +#define DEFINE_SINGLETON( T ) \ + SINGLETON_EXTERN template class SINGLETON_EXPORT Singleton< T >; + template< class T > class Singleton : private noncopyable { @@ -29,7 +36,7 @@ class Singleton : private noncopyable { } - ~Singleton( ) + virtual ~Singleton( ) { destroyed = true; } @@ -44,7 +51,7 @@ class Singleton : private noncopyable { throw std::runtime_error( "singleton has already been destroyed!" ); } - + static scopedPtr<T> t; static bool destroyed; }; |