$search
00001 /* -*- C++ -*- 00002 * $Id: dummy.hh 990 2005-09-14 15:17:04Z sjoyeux $ 00003 */ 00004 #ifndef UTILMM_SINGLETON_DUMMY_HEADER 00005 # define UTILMM_SINGLETON_DUMMY_HEADER 00006 00007 # include <string> 00008 #include <boost/utility.hpp> 00009 00010 #include "utilmm/singleton/bits/server_fwd.hh" 00011 00012 namespace utilmm { 00013 namespace singleton { 00014 class dummy; 00015 00016 namespace details { 00017 struct dummy_factory { 00018 virtual ~dummy_factory() {}; 00019 virtual dummy* create() const = 0; 00020 }; 00021 } 00022 00032 class dummy :public ::boost::noncopyable { 00033 protected: 00035 dummy(); 00037 virtual ~dummy() =0; 00038 00048 static void attach(std::string const &name, details::dummy_factory const& factory); 00057 static void detach(std::string const &name); 00058 00066 static dummy *instance(std::string const &name); 00067 00068 private: 00069 void incr_ref() const; 00070 bool decr_ref() const; 00071 00072 mutable size_t ref_counter; 00073 00074 friend class utilmm::singleton::server; 00075 }; // class utilmm::singleton::dummy 00076 00077 } // namespace utilmm::singleton 00078 } // namespace utilmm 00079 00080 #endif // UTILMM_SINGLETON_DUMMY_HEADER 00081