$search
00001 /* -*- C++ -*- 00002 * $Id: server.hh 970 2005-04-08 16:30:46Z sjoyeux $ 00003 */ 00004 #ifndef UTILMM_SINGLETON_SERVER_HEADER 00005 # define UTILMM_SINGLETON_SERVER_HEADER 00006 00007 # include <map> 00008 00009 # include "boost/thread/recursive_mutex.hpp" 00010 00011 # include "utilmm/singleton/bits/dummy.hh" 00012 00013 namespace utilmm { 00014 namespace singleton { 00015 00025 class server :public ::boost::noncopyable { 00026 private: 00027 server(); 00028 ~server(); 00029 00030 static server &instance(); 00031 00032 void attach(std::string const &name, details::dummy_factory const& factory); 00033 bool detach(std::string const &name); 00034 00035 dummy *get(std::string const &name) const; 00036 00037 typedef std::map<std::string, dummy *> single_map; 00038 00039 single_map singletons; 00040 00041 static server *the_instance; 00042 00043 typedef boost::recursive_mutex mutex_type; 00044 typedef mutex_type::scoped_lock lock_type; 00045 00046 static mutex_type sing_mtx; 00047 00048 friend class utilmm::singleton::dummy; 00049 }; // class utilmm::singleton::server 00050 00051 } // namespace utilmm::singleton 00052 } // namespace utilmm 00053 00054 #endif // UTILMM_SINGLETON_SERVER_HEADER 00055