Gaudi Framework, version v20r3

Generated: 24 Nov 2008

PoolDbCacheSvc Class Reference

#include <PoolDb/PoolDbCacheSvc.h>

Inheritance diagram for PoolDbCacheSvc:

Inheritance graph
[legend]
Collaboration diagram for PoolDbCacheSvc:

Collaboration graph
[legend]

List of all members.


Detailed Description

Description:.

The PoolCacheMgr service interface allows to access special functionality provided by the POOL persistency interface.

Author:
Markus Frank
Version:
1.0

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::DbSessionsession ()
 Access the (single) POOL database session.
virtual StatusCode loadDictionary (const std::string &name)
 Load dictionary library.
virtual pool::DbOptionCallbackcallbackHandler () const
 Access to POOL callback handler.
virtual pool::DbStatus setMyOptions (pool::IDbOptionProxy *pObj, pool::DbOptionCallback::OptionType typ, const std::string &name)
 Default callback (does nothing).
virtual pool::DbStatus setCallbackOptions (pool::IDbOptionProxy *pObj, const std::vector< std::string > &v, const std::string &name)
 Set callback specific options.

Protected Member Functions

StatusCode loadLibraries ()
 Load all required libraries.

Protected Attributes

pool::DbSession m_session
 The POOL database session.
pool::DbOptionCallbackm_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::ImageHandlem_sharedHdls
 Shared Gaudi libraries.

Constructor & Destructor Documentation

PoolDbCacheSvc::PoolDbCacheSvc ( const std::string &  name,
ISvcLocator svc 
)

Standard constructor.

Definition at line 58 of file PoolDbCacheSvc.cpp.

00059   : Service(nam, svc), m_callbackHandler(0)
00060 {
00061   s_count->increment();
00062   m_callbackHandler = this;
00063   declareProperty("Dlls",               m_dlls);
00064   declareProperty("DomainOpts",         m_domainOpts);
00065   declareProperty("DatabaseOpts",       m_databaseOpts);
00066   declareProperty("DatabaseOnOpenOpts", m_databaseOpenOpts);
00067   declareProperty("ContainerOpts",      m_containerOpts);
00068   declareProperty("ContainerOnOpenOpts",m_containerOpenOpts);
00069 }

PoolDbCacheSvc::~PoolDbCacheSvc (  )  [virtual]

Standard destructor.

Definition at line 72 of file PoolDbCacheSvc.cpp.

00073 {
00074   s_count->decrement();
00075 }


Member Function Documentation

StatusCode PoolDbCacheSvc::loadLibraries (  )  [protected]

Load all required libraries.

Definition at line 213 of file PoolDbCacheSvc.cpp.

00213                                           {
00214   StatusCode status = StatusCode::SUCCESS;
00215   if ( !m_dlls.empty() )  {
00216     std::vector<std::string>::const_iterator i;
00217     for(i=m_dlls.begin(); i != m_dlls.end(); ++i)  {
00218       StatusCode iret = loadDictionary(*i);
00219       if ( !iret.isSuccess() )  {
00220         status = iret;
00221       }
00222     }
00223   }
00224   return status;
00225 }

StatusCode PoolDbCacheSvc::queryInterface ( const InterfaceID riid,
void **  ppvInterface 
) [virtual]

Service overload: Query interface.

Reimplemented from Service.

Definition at line 78 of file PoolDbCacheSvc.cpp.

00079 {
00080   if ( IPoolCacheSvc::interfaceID().versionMatch(riid) )  {
00081     *ppvInterface = (IPoolCacheSvc*)this;
00082     addRef();
00083     return StatusCode::SUCCESS;
00084   }
00085   // Interface is not directly availible: try out a base class
00086   return Service::queryInterface(riid, ppvInterface);
00087 }

StatusCode PoolDbCacheSvc::initialize (  )  [virtual]

Service overload: initialize service.

Reimplemented from Service.

Definition at line 90 of file PoolDbCacheSvc.cpp.

00090                                        {
00091   StatusCode status = Service::initialize();
00092   MsgStream log(messageService(), name());
00093   if ( !status.isSuccess() ) {
00094     log << MSG::ERROR << "Failed to initialize Service base class."
00095         << endmsg;
00096     return status;
00097   }
00098   coral::MessageStream::installMsgReporter(new PoolDbMsgReporter(messageService(),m_outputLevel.value()));
00099   coral::MessageStream::setMsgVerbosity(static_cast<coral::MsgLevel>(m_outputLevel.value()));
00100 
00101   log << MSG::INFO << "POOL output threshold:" << m_outputLevel
00102       << endmsg;
00103   status = loadLibraries();
00104   if ( !status.isSuccess() ) {
00105     log << MSG::ERROR << "Failed to load POOL libraries."
00106         << endmsg;
00107     return status;
00108   }
00109   session().open(0);
00110   // All dictionaries should be loaded. Let's patch the streamers
00111   // for ContainedObject, DataObject and SmartRefbase
00112   if ( !GaudiPoolDb::patchStreamers(log) )  {
00113     log << MSG::ERROR << "Failed to install customized IO!" << endmsg;
00114     return StatusCode::FAILURE;
00115   }
00116   return status;
00117 }

StatusCode PoolDbCacheSvc::finalize ( void   )  [virtual]

Service overload: Finalize service.

Shared Gaudi libraries

Reimplemented from Service.

Definition at line 120 of file PoolDbCacheSvc.cpp.

00120                                       {
00121   MsgStream log(messageService(), name());
00122   session().close();
00124   std::vector<System::ImageHandle>::iterator i;
00125   for(i=m_sharedHdls.begin(); i != m_sharedHdls.end(); ++i)  {
00126     if ( *i ) {
00127       // System::unloadDynamicLib(*i);
00128     }
00129   }
00130   m_sharedHdls.clear();
00131   coral::MessageStream::installMsgReporter(0);
00132   return Service::finalize();
00133 }

virtual pool::DbSession& PoolDbCacheSvc::session (  )  [inline, virtual]

Access the (single) POOL database session.

Returns:
Reference to POOL session handle

Implements IPoolCacheSvc.

Definition at line 89 of file PoolDbCacheSvc.h.

00089                                       {
00090     return m_session;
00091   }

StatusCode PoolDbCacheSvc::loadDictionary ( const std::string &  name  )  [virtual]

Load dictionary library.

Parameters:
name [IN] dictionary name/file path
Returns:
Status code indicating success or failure

Implements IPoolCacheSvc.

Definition at line 228 of file PoolDbCacheSvc.cpp.

00228                                                               {
00229   System::ImageHandle hdl = 0;
00230   StatusCode status = System::loadDynamicLib(nam, &hdl);
00231   if ( !status.isSuccess() )  {
00232     MsgStream log(messageService(), name());
00233     log << MSG::ERROR << System::getLastErrorString() << endmsg
00234         << "Failed to load POOL implementation library:"
00235         << nam << endmsg;
00236     return status;
00237   }
00238   m_sharedHdls.push_back(hdl);
00239   return status;
00240 }

virtual pool::DbOptionCallback* PoolDbCacheSvc::callbackHandler (  )  const [inline, virtual]

Access to POOL callback handler.

Returns:
Reference to POOL callback handler

Implements IPoolCacheSvc.

Definition at line 103 of file PoolDbCacheSvc.h.

00103                                                          {
00104     return m_callbackHandler;
00105   }

pool::DbStatus PoolDbCacheSvc::setMyOptions ( pool::IDbOptionProxy pObj,
pool::DbOptionCallback::OptionType  typ,
const std::string &  name 
) [virtual]

Default callback (does nothing).

Parameters:
pObj [IN] Reference to object receiving options
typ [IN] Object type to receive options
name [IN] Object's name.
Returns:
Status code indicating success or failure.

Reimplemented from pool::DbOptionCallback.

Definition at line 191 of file PoolDbCacheSvc.cpp.

00194 {
00195   switch (typ)  {
00196     case pool::DbOptionCallback::_DOMAIN_OPT:
00197       return setCallbackOptions(pObj, m_domainOpts, name);
00198     case pool::DbOptionCallback::_DATABASE_OPT:
00199       return setCallbackOptions(pObj, m_databaseOpts, name);
00200     case pool::DbOptionCallback::_DATABASE_ONOPEN:
00201       return setCallbackOptions(pObj, m_databaseOpenOpts, name);
00202     case pool::DbOptionCallback::_CONTAINER_OPT:
00203       return setCallbackOptions(pObj, m_containerOpts, name);
00204     case pool::DbOptionCallback::_CONTAINER_ONOPEN:
00205       return setCallbackOptions(pObj, m_containerOpenOpts, name);
00206     default:
00207       break;
00208   }
00209   return pool::Error;
00210 }

pool::DbStatus PoolDbCacheSvc::setCallbackOptions ( pool::IDbOptionProxy pObj,
const std::vector< std::string > &  v,
const std::string &  name 
) [virtual]

Set callback specific options.

Set container specific options.

Parameters:
pObj [IN] Reference to object receiving options
name [IN] Object's name.
Returns:
Status code indicating success or failure.

Definition at line 137 of file PoolDbCacheSvc.cpp.

00140 {
00141   std::string opt_nam, opt_val, opt_typ;
00142   typedef std::vector<std::string> StringV;
00143   for (StringV::const_iterator i=v.begin(); i!=v.end(); ++i)  {
00144     const std::string& id = *i;
00145     if ( id.length() > obj.length() )   {
00146       if ( obj == id.substr(0, obj.length()) )  {
00147         std::string n = id.substr(obj.length()+1);
00148         size_t idx = n.find("=");
00149         size_t idx2 = n.find("TYP=");
00150         if ( idx != std::string::npos && idx2 != std::string::npos )  {
00151           opt_nam = n.substr(0, idx);
00152           opt_val = n.substr(idx+1, idx2-2-idx);
00153           opt_typ = n.substr(idx2+4,1);
00154           std::stringstream s(opt_val);
00155           pool::DbOption opt(opt_nam);
00156           float fval;
00157           int   ival;
00158           long long int lval;
00159           switch(::toupper(opt_typ[0])) {
00160             case 'I':
00161               s >> ival;
00162               opt._setValue(ival);
00163               pObj->setOption(opt);
00164               break;
00165             case 'L':
00166               s >> lval;
00167               opt._setValue(lval);
00168               pObj->setOption(opt);
00169               break;
00170             case 'F':
00171               s >> fval;
00172               opt._setValue(fval);
00173               pObj->setOption(opt);
00174               break;
00175             case 'S':
00176               opt._setValue(opt_val.c_str());
00177               pObj->setOption(opt);
00178               break;
00179             default:
00180               break;
00181           }
00182         }
00183       }
00184     }
00185   }
00186   return pool::Success;
00187 }


Member Data Documentation

The POOL database session.

Definition at line 39 of file PoolDbCacheSvc.h.

Reference to POOL callback handler.

Definition at line 42 of file PoolDbCacheSvc.h.

std::vector<std::string> PoolDbCacheSvc::m_dlls [protected]

Driver DLL to be loaded at initialization.

Definition at line 45 of file PoolDbCacheSvc.h.

std::vector<std::string> PoolDbCacheSvc::m_domainOpts [protected]

Buffer for domain options.

Definition at line 48 of file PoolDbCacheSvc.h.

std::vector<std::string> PoolDbCacheSvc::m_databaseOpts [protected]

Buffer for database options.

Definition at line 51 of file PoolDbCacheSvc.h.

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.

std::vector<std::string> PoolDbCacheSvc::m_containerOpts [protected]

Buffer for container options.

Definition at line 57 of file PoolDbCacheSvc.h.

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.

Shared Gaudi libraries.

Definition at line 63 of file PoolDbCacheSvc.h.


The documentation for this class was generated from the following files:

Generated at Mon Nov 24 14:46:11 2008 for Gaudi Framework, version v20r3 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004