![]() |
|
|
Generated: 18 Jul 2008 |
#include <PoolDb/PoolDbCacheSvc.h>
Inheritance diagram for PoolDbCacheSvc:


The PoolCacheMgr service interface allows to access special functionality provided by the POOL persistency interface.
Definition at line 32 of file PoolDbCacheSvc.h.
Public Member Functions | ||||
| PoolDbCacheSvc (const std::string &name, ISvcLocator *svc) | ||||
| Standard constructor. | ||||
| virtual | ~PoolDbCacheSvc () | |||
| Standard destructor. | ||||
| virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface) | |||
| Service overload: Query interface. | ||||
| virtual StatusCode | initialize () | |||
| Service overload: initialize service. | ||||
| virtual StatusCode | finalize () | |||
| Service overload: Finalize service. | ||||
| virtual pool::DbSession & | session () | |||
| Access the (single) POOL database session. | ||||
| virtual StatusCode | loadDictionary (const std::string &name) | |||
| ||||
| virtual pool::DbOptionCallback * | callbackHandler () const | |||
| Access to POOL callback handler. | ||||
| virtual pool::DbStatus | setMyOptions (pool::IDbOptionProxy *pObj, pool::DbOptionCallback::OptionType typ, const std::string &name) | |||
| ||||
| virtual pool::DbStatus | setCallbackOptions (pool::IDbOptionProxy *pObj, const std::vector< std::string > &v, const std::string &name) | |||
| ||||
Protected Member Functions | ||||
| StatusCode | loadLibraries () | |||
| Load all required libraries. | ||||
Protected Attributes | ||||
| pool::DbSession | m_session | |||
| The POOL database session. | ||||
| pool::DbOptionCallback * | m_callbackHandler | |||
| Reference to POOL callback handler. | ||||
| std::vector< std::string > | m_dlls | |||
| Driver DLL to be loaded at initialization. | ||||
| std::vector< std::string > | m_domainOpts | |||
| Buffer for domain options. | ||||
| std::vector< std::string > | m_databaseOpts | |||
| Buffer for database options. | ||||
| std::vector< std::string > | m_databaseOpenOpts | |||
| Buffer for database options to be set after "open". | ||||
| std::vector< std::string > | m_containerOpts | |||
| Buffer for container options. | ||||
| std::vector< std::string > | m_containerOpenOpts | |||
| Buffer for container options to be set after "open". | ||||
| std::vector< System::ImageHandle > | m_sharedHdls | |||
| Shared Gaudi libraries. | ||||
| PoolDbCacheSvc::PoolDbCacheSvc | ( | const std::string & | name, | |
| ISvcLocator * | svc | |||
| ) |
Standard constructor.
Definition at line 54 of file PoolDbCacheSvc.cpp.
References Service::declareProperty(), pool::DbInstanceCount::Counter::increment(), m_callbackHandler, m_containerOpenOpts, m_containerOpts, m_databaseOpenOpts, m_databaseOpts, m_dlls, m_domainOpts, and s_count.
00055 : Service(nam, svc), m_callbackHandler(0) 00056 { 00057 s_count->increment(); 00058 m_callbackHandler = this; 00059 declareProperty("Dlls", m_dlls); 00060 declareProperty("DomainOpts", m_domainOpts); 00061 declareProperty("DatabaseOpts", m_databaseOpts); 00062 declareProperty("DatabaseOnOpenOpts", m_databaseOpenOpts); 00063 declareProperty("ContainerOpts", m_containerOpts); 00064 declareProperty("ContainerOnOpenOpts",m_containerOpenOpts); 00065 }
| PoolDbCacheSvc::~PoolDbCacheSvc | ( | ) | [virtual] |
Standard destructor.
Definition at line 68 of file PoolDbCacheSvc.cpp.
References pool::DbInstanceCount::Counter::decrement(), and s_count.
| StatusCode PoolDbCacheSvc::loadLibraries | ( | ) | [protected] |
Load all required libraries.
Definition at line 209 of file PoolDbCacheSvc.cpp.
References loadDictionary(), m_dlls, and StatusCode::SUCCESS.
Referenced by initialize().
00209 { 00210 StatusCode status = StatusCode::SUCCESS; 00211 if ( !m_dlls.empty() ) { 00212 std::vector<std::string>::const_iterator i; 00213 for(i=m_dlls.begin(); i != m_dlls.end(); ++i) { 00214 StatusCode iret = loadDictionary(*i); 00215 if ( !iret.isSuccess() ) { 00216 status = iret; 00217 } 00218 } 00219 } 00220 return status; 00221 }
| StatusCode PoolDbCacheSvc::queryInterface | ( | const InterfaceID & | riid, | |
| void ** | ppvInterface | |||
| ) | [virtual] |
Service overload: Query interface.
Reimplemented from Service.
Definition at line 74 of file PoolDbCacheSvc.cpp.
References Service::addRef(), IPoolCacheSvc::interfaceID(), Service::queryInterface(), and StatusCode::SUCCESS.
00075 { 00076 if ( IPoolCacheSvc::interfaceID().versionMatch(riid) ) { 00077 *ppvInterface = (IPoolCacheSvc*)this; 00078 addRef(); 00079 return StatusCode::SUCCESS; 00080 } 00081 // Interface is not directly availible: try out a base class 00082 return Service::queryInterface(riid, ppvInterface); 00083 }
| StatusCode PoolDbCacheSvc::initialize | ( | ) | [virtual] |
Service overload: initialize service.
Reimplemented from Service.
Definition at line 86 of file PoolDbCacheSvc.cpp.
References endmsg(), MSG::ERROR, StatusCode::FAILURE, MSG::INFO, Service::initialize(), StatusCode::isSuccess(), loadLibraries(), Service::m_outputLevel, Service::messageService(), Service::name(), pool::DbSession::open(), GaudiPoolDb::patchStreamers(), session(), and PropertyWithValue< TYPE >::value().
00086 { 00087 StatusCode status = Service::initialize(); 00088 MsgStream log(messageService(), name()); 00089 if ( !status.isSuccess() ) { 00090 log << MSG::ERROR << "Failed to initialize Service base class." 00091 << endmsg; 00092 return status; 00093 } 00094 coral::MessageStream::installMsgReporter(new PoolDbMsgReporter(messageService(),m_outputLevel.value())); 00095 coral::MessageStream::setMsgVerbosity(static_cast<coral::MsgLevel>(m_outputLevel.value())); 00096 00097 log << MSG::INFO << "POOL output threshold:" << m_outputLevel 00098 << endmsg; 00099 status = loadLibraries(); 00100 if ( !status.isSuccess() ) { 00101 log << MSG::ERROR << "Failed to load POOL libraries." 00102 << endmsg; 00103 return status; 00104 } 00105 session().open(0); 00106 // All dictionaries should be loaded. Let's patch the streamers 00107 // for ContainedObject, DataObject and SmartRefbase 00108 if ( !GaudiPoolDb::patchStreamers(log) ) { 00109 log << MSG::ERROR << "Failed to install customized IO!" << endmsg; 00110 return StatusCode::FAILURE; 00111 } 00112 return status; 00113 }
| StatusCode PoolDbCacheSvc::finalize | ( | ) | [virtual] |
Service overload: Finalize service.
Shared Gaudi libraries
Reimplemented from Service.
Definition at line 116 of file PoolDbCacheSvc.cpp.
References pool::DbSession::close(), Service::finalize(), m_sharedHdls, Service::messageService(), Service::name(), and session().
00116 { 00117 MsgStream log(messageService(), name()); 00118 session().close(); 00120 std::vector<System::ImageHandle>::iterator i; 00121 for(i=m_sharedHdls.begin(); i != m_sharedHdls.end(); ++i) { 00122 if ( *i ) { 00123 // System::unloadDynamicLib(*i); 00124 } 00125 } 00126 m_sharedHdls.clear(); 00127 coral::MessageStream::installMsgReporter(0); 00128 return Service::finalize(); 00129 }
| virtual pool::DbSession& PoolDbCacheSvc::session | ( | ) | [inline, virtual] |
Access the (single) POOL database session.
Implements IPoolCacheSvc.
Definition at line 89 of file PoolDbCacheSvc.h.
References m_session.
Referenced by finalize(), and initialize().
00089 { 00090 return m_session; 00091 }
| StatusCode PoolDbCacheSvc::loadDictionary | ( | const std::string & | name | ) | [virtual] |
| name | [IN] dictionary name/file path |
Implements IPoolCacheSvc.
Definition at line 224 of file PoolDbCacheSvc.cpp.
References endmsg(), MSG::ERROR, System::getLastErrorString(), StatusCode::isSuccess(), System::loadDynamicLib(), m_sharedHdls, Service::messageService(), and Service::name().
Referenced by loadLibraries().
00224 { 00225 System::ImageHandle hdl = 0; 00226 StatusCode status = System::loadDynamicLib(nam, &hdl); 00227 if ( !status.isSuccess() ) { 00228 MsgStream log(messageService(), name()); 00229 log << MSG::ERROR << System::getLastErrorString() << endmsg 00230 << "Failed to load POOL implementation library:" 00231 << nam << endmsg; 00232 return status; 00233 } 00234 m_sharedHdls.push_back(hdl); 00235 return status; 00236 }
| virtual pool::DbOptionCallback* PoolDbCacheSvc::callbackHandler | ( | ) | const [inline, virtual] |
Access to POOL callback handler.
Implements IPoolCacheSvc.
Definition at line 103 of file PoolDbCacheSvc.h.
References m_callbackHandler.
00103 { 00104 return m_callbackHandler; 00105 }
| pool::DbStatus PoolDbCacheSvc::setMyOptions | ( | pool::IDbOptionProxy * | pObj, | |
| pool::DbOptionCallback::OptionType | typ, | |||
| const std::string & | name | |||
| ) | [virtual] |
| pObj | [IN] Reference to object receiving options |
| typ | [IN] Object type to receive options | |
| name | [IN] Object's name. |
Reimplemented from pool::DbOptionCallback.
Definition at line 187 of file PoolDbCacheSvc.cpp.
References pool::DbOptionCallback::_CONTAINER_ONOPEN, pool::DbOptionCallback::_CONTAINER_OPT, pool::DbOptionCallback::_DATABASE_ONOPEN, pool::DbOptionCallback::_DATABASE_OPT, pool::DbOptionCallback::_DOMAIN_OPT, pool::Error, m_containerOpenOpts, m_containerOpts, m_databaseOpenOpts, m_databaseOpts, m_domainOpts, Service::name(), and setCallbackOptions().
00190 { 00191 switch (typ) { 00192 case pool::DbOptionCallback::_DOMAIN_OPT: 00193 return setCallbackOptions(pObj, m_domainOpts, name); 00194 case pool::DbOptionCallback::_DATABASE_OPT: 00195 return setCallbackOptions(pObj, m_databaseOpts, name); 00196 case pool::DbOptionCallback::_DATABASE_ONOPEN: 00197 return setCallbackOptions(pObj, m_databaseOpenOpts, name); 00198 case pool::DbOptionCallback::_CONTAINER_OPT: 00199 return setCallbackOptions(pObj, m_containerOpts, name); 00200 case pool::DbOptionCallback::_CONTAINER_ONOPEN: 00201 return setCallbackOptions(pObj, m_containerOpenOpts, name); 00202 default: 00203 break; 00204 } 00205 return pool::Error; 00206 }
| pool::DbStatus PoolDbCacheSvc::setCallbackOptions | ( | pool::IDbOptionProxy * | pObj, | |
| const std::vector< std::string > & | v, | |||
| const std::string & | name | |||
| ) | [virtual] |
| pObj | [IN] Reference to object receiving options |
| name | [IN] Object's name. |
Definition at line 133 of file PoolDbCacheSvc.cpp.
References pool::DbOption::_setValue(), std::vector< _Tp, _Alloc >::begin(), std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::vector< _Tp, _Alloc >::end(), std::basic_string< _CharT, _Traits, _Alloc >::find(), std::basic_string< _CharT, _Traits, _Alloc >::length(), std::basic_string< _CharT, _Traits, _Alloc >::npos, Gaudi::Units::s, pool::IDbOptionProxy::setOption(), std::basic_string< _CharT, _Traits, _Alloc >::substr(), pool::Success, and toupper().
Referenced by setMyOptions().
00136 { 00137 std::string opt_nam, opt_val, opt_typ; 00138 typedef std::vector<std::string> StringV; 00139 for (StringV::const_iterator i=v.begin(); i!=v.end(); ++i) { 00140 const std::string& id = *i; 00141 if ( id.length() > obj.length() ) { 00142 if ( obj == id.substr(0, obj.length()) ) { 00143 std::string n = id.substr(obj.length()+1); 00144 size_t idx = n.find("="); 00145 size_t idx2 = n.find("TYP="); 00146 if ( idx != std::string::npos && idx2 != std::string::npos ) { 00147 opt_nam = n.substr(0, idx); 00148 opt_val = n.substr(idx+1, idx2-2-idx); 00149 opt_typ = n.substr(idx2+4,1); 00150 std::stringstream s(opt_val); 00151 pool::DbOption opt(opt_nam); 00152 float fval; 00153 int ival; 00154 long long int lval; 00155 switch(::toupper(opt_typ[0])) { 00156 case 'I': 00157 s >> ival; 00158 opt._setValue(ival); 00159 pObj->setOption(opt); 00160 break; 00161 case 'L': 00162 s >> lval; 00163 opt._setValue(lval); 00164 pObj->setOption(opt); 00165 break; 00166 case 'F': 00167 s >> fval; 00168 opt._setValue(fval); 00169 pObj->setOption(opt); 00170 break; 00171 case 'S': 00172 opt._setValue(opt_val.c_str()); 00173 pObj->setOption(opt); 00174 break; 00175 default: 00176 break; 00177 } 00178 } 00179 } 00180 } 00181 } 00182 return pool::Success; 00183 }
pool::DbSession PoolDbCacheSvc::m_session [protected] |
pool::DbOptionCallback* PoolDbCacheSvc::m_callbackHandler [protected] |
Reference to POOL callback handler.
Definition at line 42 of file PoolDbCacheSvc.h.
Referenced by callbackHandler(), and PoolDbCacheSvc().
std::vector<std::string> PoolDbCacheSvc::m_dlls [protected] |
Driver DLL to be loaded at initialization.
Definition at line 45 of file PoolDbCacheSvc.h.
Referenced by loadLibraries(), and PoolDbCacheSvc().
std::vector<std::string> PoolDbCacheSvc::m_domainOpts [protected] |
Buffer for domain options.
Definition at line 48 of file PoolDbCacheSvc.h.
Referenced by PoolDbCacheSvc(), and setMyOptions().
std::vector<std::string> PoolDbCacheSvc::m_databaseOpts [protected] |
Buffer for database options.
Definition at line 51 of file PoolDbCacheSvc.h.
Referenced by PoolDbCacheSvc(), and setMyOptions().
std::vector<std::string> PoolDbCacheSvc::m_databaseOpenOpts [protected] |
Buffer for database options to be set after "open".
Definition at line 54 of file PoolDbCacheSvc.h.
Referenced by PoolDbCacheSvc(), and setMyOptions().
std::vector<std::string> PoolDbCacheSvc::m_containerOpts [protected] |
Buffer for container options.
Definition at line 57 of file PoolDbCacheSvc.h.
Referenced by PoolDbCacheSvc(), and setMyOptions().
std::vector<std::string> PoolDbCacheSvc::m_containerOpenOpts [protected] |
Buffer for container options to be set after "open".
Definition at line 60 of file PoolDbCacheSvc.h.
Referenced by PoolDbCacheSvc(), and setMyOptions().
std::vector<System::ImageHandle> PoolDbCacheSvc::m_sharedHdls [protected] |
Shared Gaudi libraries.
Definition at line 63 of file PoolDbCacheSvc.h.
Referenced by finalize(), and loadDictionary().