libmoost
/home/mhx/git/github/libmoost/include/moost/utils/singleton.hpp
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #ifndef MOOST_UTILS_SINGLETON_HPP__
00029 #define MOOST_UTILS_SINGLETON_HPP__
00030 
00031 #include <boost/serialization/singleton.hpp>
00032 
00033 namespace moost { namespace utils {
00034 
00035    template <typename T>
00036    class singleton_default : boost::serialization::singleton<T>
00037    {
00038       private:
00039          singleton_default();
00040 
00041       public:
00042          typedef T object_type;
00043          static object_type & instance()
00044          {
00045             return boost::serialization::singleton<T>::get_mutable_instance();
00046          }
00047 
00048          // Befriend to allow your singleton class to have a private constructor
00049          typedef boost::serialization::detail::singleton_wrapper<T> friend_type;
00050    };
00051 
00052 
00053 }}
00054 
00055 #endif // MOOST_UTILS_SINGLETON_HPP__