00001 /*------------------------------------------------------------------------------ 00002 Name: SocketDriverFactory.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Comment: The factory for the client driver for the SOCKET protocol 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _CLIENT_PROTOCOL_SOCKET_SOCKETDRIVERFACTORY 00008 #define _CLIENT_PROTOCOL_SOCKET_SOCKETDRIVERFACTORY 00009 00010 #include <util/xmlBlasterDef.h> 00011 #include <client/protocol/socket/SocketDriver.h> 00012 #include <util/objman.h> // for managed objects 00013 00014 namespace org { 00015 namespace xmlBlaster { 00016 namespace client { 00017 namespace protocol { 00018 namespace socket { 00019 00020 typedef std::pair<SocketDriver*, int> DriverEntry; 00021 typedef std::map<org::xmlBlaster::util::Global*, DriverEntry> DriversMap; 00022 00028 class Dll_Export SocketDriverFactory 00029 { 00030 friend SocketDriverFactory& getFactory(org::xmlBlaster::util::Global& global); 00031 00032 // required for the managed objects 00033 friend class Object_Lifetime_Manager; 00034 friend class ManagedObject; 00035 00036 private: 00037 const std::string ME; 00038 DriversMap drivers_; //< the std::map containing all drivers created by this factory 00039 org::xmlBlaster::util::thread::Mutex getterMutex_; //< the mutex used for creating/deleting SocketDriver instances 00040 00041 static SocketDriverFactory* factory_; 00042 00044 void run(); 00045 00046 SocketDriverFactory(org::xmlBlaster::util::Global& global); 00047 00048 SocketDriverFactory(const SocketDriverFactory& factory); 00049 SocketDriverFactory& operator =(const SocketDriverFactory& factory); 00050 00051 public: 00052 ~SocketDriverFactory(); // Should be private, VC7 is ok with private, g++ 3.3 does not like it 00053 00056 static SocketDriverFactory& getFactory(org::xmlBlaster::util::Global& global); 00057 00061 SocketDriver& getDriverInstance(org::xmlBlaster::util::Global* global); 00062 00068 int killDriverInstance(org::xmlBlaster::util::Global* global); 00069 00070 }; 00071 00072 }}}}} // namespaces 00073 00074 #endif