Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

PoolDbCacheSvc Class Reference

Description:. More...

#include <PoolDb/PoolDbCacheSvc.h>

Inheritance diagram for PoolDbCacheSvc:
Inheritance graph
[legend]
Collaboration diagram for PoolDbCacheSvc:
Collaboration graph
[legend]

List of all members.

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::stringm_dlls
 Driver DLL to be loaded at initialization.
std::vector< std::stringm_domainOpts
 Buffer for domain options.
std::vector< std::stringm_databaseOpts
 Buffer for database options.
std::vector< std::stringm_databaseOpenOpts
 Buffer for database options to be set after "open".
std::vector< std::stringm_containerOpts
 Buffer for container options.
std::vector< std::stringm_containerOpenOpts
 Buffer for container options to be set after "open".
std::vector< System::ImageHandlem_sharedHdls
 Shared Gaudi libraries.

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.


Constructor & Destructor Documentation

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

Standard constructor.

Definition at line 63 of file PoolDbCacheSvc.cpp.

00064   : base_class(nam, svc), m_callbackHandler(0)
00065 {
00066   s_count->increment();
00067   m_callbackHandler = this;
00068   declareProperty("Dlls",               m_dlls);
00069   declareProperty("DomainOpts",         m_domainOpts);
00070   declareProperty("DatabaseOpts",       m_databaseOpts);
00071   declareProperty("DatabaseOnOpenOpts", m_databaseOpenOpts);
00072   declareProperty("ContainerOpts",      m_containerOpts);
00073   declareProperty("ContainerOnOpenOpts",m_containerOpenOpts);
00074 }

PoolDbCacheSvc::~PoolDbCacheSvc (  )  [virtual]

Standard destructor.

Definition at line 77 of file PoolDbCacheSvc.cpp.

00078 {
00079   s_count->decrement();
00080 }


Member Function Documentation

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   }

StatusCode PoolDbCacheSvc::finalize (  )  [virtual]

Service overload: Finalize service.

Shared Gaudi libraries

Reimplemented from Service.

Definition at line 113 of file PoolDbCacheSvc.cpp.

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

StatusCode PoolDbCacheSvc::initialize (  )  [virtual]

Service overload: initialize service.

Reimplemented from Service.

Definition at line 83 of file PoolDbCacheSvc.cpp.

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

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

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

StatusCode PoolDbCacheSvc::loadLibraries (  )  [protected]

Load all required libraries.

Definition at line 206 of file PoolDbCacheSvc.cpp.

00206                                           {
00207   StatusCode status = StatusCode::SUCCESS;
00208   if ( !m_dlls.empty() )  {
00209     std::vector<std::string>::const_iterator i;
00210     for(i=m_dlls.begin(); i != m_dlls.end(); ++i)  {
00211       StatusCode iret = loadDictionary(*i);
00212       if ( !iret.isSuccess() )  {
00213         status = iret;
00214       }
00215     }
00216   }
00217   return status;
00218 }

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   }

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

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

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.

Definition at line 184 of file PoolDbCacheSvc.cpp.

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


Member Data Documentation

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

Reference to POOL callback handler.

Definition at line 41 of file PoolDbCacheSvc.h.

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

Definition at line 59 of file PoolDbCacheSvc.h.

Buffer for container options.

Definition at line 56 of file PoolDbCacheSvc.h.

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

Definition at line 53 of file PoolDbCacheSvc.h.

Buffer for database options.

Definition at line 50 of file PoolDbCacheSvc.h.

Driver DLL to be loaded at initialization.

Definition at line 44 of file PoolDbCacheSvc.h.

Buffer for domain options.

Definition at line 47 of file PoolDbCacheSvc.h.

pool::DbSession PoolDbCacheSvc::m_session [protected]

The POOL database session.

Definition at line 38 of file PoolDbCacheSvc.h.

Shared Gaudi libraries.

Definition at line 62 of file PoolDbCacheSvc.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Wed Feb 9 16:31:33 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004