| # Gaudi Framework, version v21r6 |

Home |  | Generated: 11 Nov 2009

# PoolDbCacheSvc Class Reference

`#include <PoolDb/PoolDbCacheSvc.h>`

Inheritance diagram for PoolDbCacheSvc:

[legend]
Collaboration diagram for PoolDbCacheSvc:

[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 | 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)
| Load dictionary library.
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)
| 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::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.

## Constructor & Destructor Documentation

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

Standard constructor.

Definition at line 58 of file PoolDbCacheSvc.cpp.

    00059   : base_class(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 201 of file PoolDbCacheSvc.cpp.

    00201                                           {
    00202   StatusCode status = StatusCode::SUCCESS;
    00203   if ( !m_dlls.empty() )  {
    00204     std::vector<std::string>::const_iterator i;
    00205     for(i=m_dlls.begin(); i != m_dlls.end(); ++i)  {
    00206       StatusCode iret = loadDictionary(*i);
    00207       if ( !iret.isSuccess() )  {
    00208         status = iret;
    00209       }
    00210     }
    00211   }
    00212   return status;
    00213 }

StatusCode PoolDbCacheSvc::initialize | ( |  | ) | `[virtual]`

Service overload: initialize service.

Reimplemented from Service.

Definition at line 78 of file PoolDbCacheSvc.cpp.

    00078                                        {
    00079   StatusCode status = Service::initialize();
    00080   MsgStream log(msgSvc(), name());
    00081   if ( !status.isSuccess() ) {
    00082     log << MSG::ERROR << "Failed to initialize Service base class."
    00083         << endmsg;
    00084     return status;
    00085   }
    00086   coral::MessageStream::installMsgReporter(new PoolDbMsgReporter(msgSvc(),m_outputLevel.value()));
    00087   coral::MessageStream::setMsgVerbosity(static_cast<coral::MsgLevel>(m_outputLevel.value()));
    00088
    00089   log << MSG::INFO << "POOL output threshold:" << m_outputLevel
    00090       << endmsg;
    00091   status = loadLibraries();
    00092   if ( !status.isSuccess() ) {
    00093     log << MSG::ERROR << "Failed to load POOL libraries."
    00094         << endmsg;
    00095     return status;
    00096   }
    00097   session().open(0);
    00098   // All dictionaries should be loaded. Let's patch the streamers
    00099   // for ContainedObject, DataObject and SmartRefbase
    00100   if ( !GaudiPoolDb::patchStreamers(log) )  {
    00101     log << MSG::ERROR << "Failed to install customized IO!" << endmsg;
    00102     return StatusCode::FAILURE;
    00103   }
    00104   return status;
    00105 }

StatusCode PoolDbCacheSvc::finalize | ( | void |  | ) | `[virtual]`

Service overload: Finalize service.

Shared Gaudi libraries

Reimplemented from Service.

Definition at line 108 of file PoolDbCacheSvc.cpp.

    00108                                       {
    00109   MsgStream log(msgSvc(), name());
    00110   session().close();
    00112   std::vector<System::ImageHandle>::iterator i;
    00113   for(i=m_sharedHdls.begin(); i != m_sharedHdls.end(); ++i)  {
    00114     if ( *i ) {
    00115       // System::unloadDynamicLib(*i);
    00116     }
    00117   }
    00118   m_sharedHdls.clear();
    00119   coral::MessageStream::installMsgReporter(0);
    00120   return Service::finalize();
    00121 }

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

Access the (single) POOL database session.

Returns:
  Reference to POOL session handle

Implements IPoolCacheSvc.

Definition at line 85 of file PoolDbCacheSvc.h.

    00085                                       {
    00086     return m_session;
    00087   }

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 216 of file PoolDbCacheSvc.cpp.

    00216                                                               {
    00217   System::ImageHandle hdl = 0;
    00218   StatusCode status = System::loadDynamicLib(nam, &hdl);
    00219   if ( !status.isSuccess() )  {
    00220     MsgStream log(msgSvc(), name());
    00221     log << MSG::ERROR << System::getLastErrorString() << endmsg
    00222         << "Failed to load POOL implementation library:"
    00223         << nam << endmsg;
    00224     return status;
    00225   }
    00226   m_sharedHdls.push_back(hdl);
    00227   return status;
    00228 }

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

Access to POOL callback handler.

Returns:
  Reference to POOL callback handler

Implements IPoolCacheSvc.

Definition at line 99 of file PoolDbCacheSvc.h.

    00099                                                          {
    00100     return m_callbackHandler;
    00101   }

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 179 of file PoolDbCacheSvc.cpp.

    00182 {
    00183   switch (typ)  {
    00184     case pool::DbOptionCallback::_DOMAIN_OPT:
    00185       return setCallbackOptions(pObj, m_domainOpts, name);
    00186     case pool::DbOptionCallback::_DATABASE_OPT:
    00187       return setCallbackOptions(pObj, m_databaseOpts, name);
    00188     case pool::DbOptionCallback::_DATABASE_ONOPEN:
    00189       return setCallbackOptions(pObj, m_databaseOpenOpts, name);
    00190     case pool::DbOptionCallback::_CONTAINER_OPT:
    00191       return setCallbackOptions(pObj, m_containerOpts, name);
    00192     case pool::DbOptionCallback::_CONTAINER_ONOPEN:
    00193       return setCallbackOptions(pObj, m_containerOpenOpts, name);
    00194     default:
    00195       break;
    00196   }
    00197   return pool::Error;
    00198 }

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 125 of file PoolDbCacheSvc.cpp.

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

## Member Data Documentation

pool::DbSession PoolDbCacheSvc::m_session`[protected]`

The POOL database session.

Definition at line 38 of file PoolDbCacheSvc.h.

pool::DbOptionCallback* PoolDbCacheSvc::m_callbackHandler`[protected]`

Reference to POOL callback handler.

Definition at line 41 of file PoolDbCacheSvc.h.

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

Driver DLL to be loaded at initialization.

Definition at line 44 of file PoolDbCacheSvc.h.

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

Buffer for domain options.

Definition at line 47 of file PoolDbCacheSvc.h.

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

Buffer for database options.

Definition at line 50 of file PoolDbCacheSvc.h.

std::vector<std::string> PoolDbCacheSvc::m_databaseOpenOpts`[protected]`

Buffer for database options to be set after "open".

Definition at line 53 of file PoolDbCacheSvc.h.

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

Buffer for container options.

Definition at line 56 of file PoolDbCacheSvc.h.

std::vector<std::string> PoolDbCacheSvc::m_containerOpenOpts`[protected]`

Buffer for container options to be set after "open".

Definition at line 59 of file PoolDbCacheSvc.h.

std::vector<System::ImageHandle> PoolDbCacheSvc::m_sharedHdls`[protected]`

Shared Gaudi libraries.

Definition at line 62 of file PoolDbCacheSvc.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r6/GaudiPoolDb/GaudiPoolDb/PoolDbCacheSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r6/GaudiPoolDb/src/PoolDbCacheSvc.cpp