00001 /*------------------------------------------------------------------------------ 00002 Name: CorbaDriverFactory.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Comment: The Factory for the client driver for the corba protocol 00006 ------------------------------------------------------------------------------*/ 00007 00008 #ifndef _CLIENT_PROTOCOL_CORBA_CORBADRIVERFACTORY 00009 #define _CLIENT_PROTOCOL_CORBA_CORBADRIVERFACTORY 00010 00011 #include <util/xmlBlasterDef.h> 00012 #include <client/protocol/corba/CorbaDriver.h> 00013 #include <util/objman.h> // for managed objects 00014 00015 00016 00017 00018 00019 00020 namespace org { 00021 namespace xmlBlaster { 00022 namespace client { 00023 namespace protocol { 00024 namespace corba { 00025 00026 typedef std::pair<CorbaDriver*, int> DriverEntry; 00027 typedef std::map<org::xmlBlaster::util::Global*, DriverEntry> DriversMap; 00028 00047 class Dll_Export CorbaDriverFactory : public org::xmlBlaster::util::thread::Thread 00048 { 00049 friend CorbaDriverFactory& getFactory(org::xmlBlaster::util::Global& global, CORBA::ORB_ptr orb=NULL); 00050 00051 // required for the managed objects 00052 friend class Object_Lifetime_Manager; 00053 friend class ManagedObject; 00054 00055 private: 00056 const std::string ME; 00057 //org::xmlBlaster::util::Global& global_; 00058 //org::xmlBlaster::util::I_Log& log_; 00059 DriversMap drivers_; // the std::map containing all drivers created by this factory 00060 bool doRun_; // the command: if set to 'false' the thread will stop. 00061 bool isRunning_; // the status: if the thread is running it is 'true' 00062 org::xmlBlaster::util::thread::Mutex mutex_, // the mutex passed to all CorbaDriver instances (for singlethreaded) 00063 getterMutex_; // the mutex used for creating/deleting CorbaDriver instances 00064 bool orbIsThreadSafe_; // flag telling if the orb is a singletheraded or multithreaded orb 00065 CORBA::ORB_ptr orb_; // the orb used (either created here or passed in constructor 00066 bool isOwnOrb_; // 'true' if the orb has been created by this factory. 00067 00068 static CorbaDriverFactory* factory_; 00069 00087 void run(); 00088 00090 bool orbRun(); 00091 00092 CorbaDriverFactory(org::xmlBlaster::util::Global& global, CORBA::ORB_ptr orb=NULL); 00093 00094 CorbaDriverFactory(const CorbaDriverFactory& factory); 00095 CorbaDriverFactory& operator =(const CorbaDriverFactory& factory); 00096 00097 public: 00098 ~CorbaDriverFactory(); // Should be private, VC7 is ok with private, g++ 3.3 does not like it 00099 00112 static CorbaDriverFactory& getFactory(org::xmlBlaster::util::Global& global, CORBA::ORB_ptr orb=NULL); 00113 00117 CorbaDriver& getDriverInstance(org::xmlBlaster::util::Global* global); 00118 00124 int killDriverInstance(org::xmlBlaster::util::Global* global); 00125 00126 }; 00127 00128 }}}}} // namespaces 00129 00130 #endif