| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Member Functions | Protected Member Functions | Protected Attributes

# PoolDbCacheSvc Class Reference

Description: More...

`#include <PoolDb/PoolDbCacheSvc.h>`

Inheritance diagram for PoolDbCacheSvc:
[legend]
Collaboration diagram for PoolDbCacheSvc:
[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::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.

## 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.

      : base_class(nam, svc), m_callbackHandler(0)
    {
      s_count->increment();
      m_callbackHandler = this;
      declareProperty("Dlls",               m_dlls);
      declareProperty("DomainOpts",         m_domainOpts);
      declareProperty("DatabaseOpts",       m_databaseOpts);
      declareProperty("DatabaseOnOpenOpts", m_databaseOpenOpts);
      declareProperty("ContainerOpts",      m_containerOpts);
      declareProperty("ContainerOnOpenOpts",m_containerOpenOpts);
    }

PoolDbCacheSvc::~PoolDbCacheSvc | ( | ) | `[virtual]`

Standard destructor.

Definition at line 77 of file PoolDbCacheSvc.cpp.

    {
      s_count->decrement();
    }

## 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.

                                                             {
        return m_callbackHandler;
      }

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

Service overload: Finalize service.

Shared Gaudi libraries

Reimplemented from Service.

Definition at line 113 of file PoolDbCacheSvc.cpp.

                                          {
      MsgStream log(msgSvc(), name());
      session().close();
      std::vector<System::ImageHandle>::iterator i;
      for(i=m_sharedHdls.begin(); i != m_sharedHdls.end(); ++i)  {
        if ( *i ) {
          // System::unloadDynamicLib(*i);
        }
      }
      m_sharedHdls.clear();
      coral::MessageStream::installMsgReporter(0);
      return Service::finalize();
    }

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

Service overload: initialize service.

Reimplemented from Service.

Definition at line 83 of file PoolDbCacheSvc.cpp.

                                           {
      StatusCode status = Service::initialize();
      MsgStream log(msgSvc(), name());
      if ( !status.isSuccess() ) {
        log << MSG::ERROR << "Failed to initialize Service base class."
            << endmsg;
        return status;
      }
      coral::MessageStream::installMsgReporter(new PoolDbMsgReporter(msgSvc(),m_outputLevel.value()));
      coral::MessageStream::setMsgVerbosity(static_cast<coral::MsgLevel>(m_outputLevel.value()));

      log << MSG::INFO << "POOL output threshold:" << m_outputLevel
          << endmsg;
      status = loadLibraries();
      if ( !status.isSuccess() ) {
        log << MSG::ERROR << "Failed to load POOL libraries."
            << endmsg;
        return status;
      }
      session().open(0);
      // All dictionaries should be loaded. Let's patch the streamers
      // for ContainedObject, DataObject and SmartRefbase
      if ( !GaudiPoolDb::patchStreamers(log) )  {
        log << MSG::ERROR << "Failed to install customized IO!" << endmsg;
        return StatusCode::FAILURE;
      }
      return status;
    }

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.

                                                                  {
      System::ImageHandle hdl = 0;
      StatusCode status = System::loadDynamicLib(nam, &hdl);
      if ( !status.isSuccess() )  {
        MsgStream log(msgSvc(), name());
        log << MSG::ERROR << System::getLastErrorString() << endmsg
            << "Failed to load POOL implementation library:"
            << nam << endmsg;
        return status;
      }
      m_sharedHdls.push_back(hdl);
      return status;
    }

StatusCode PoolDbCacheSvc::loadLibraries | ( | ) | `[protected]`

Load all required libraries.

Definition at line 206 of file PoolDbCacheSvc.cpp.

                                              {
      StatusCode status = StatusCode::SUCCESS;
      if ( !m_dlls.empty() )  {
        std::vector<std::string>::const_iterator i;
        for(i=m_dlls.begin(); i != m_dlls.end(); ++i)  {
          StatusCode iret = loadDictionary(*i);
          if ( !iret.isSuccess() )  {
            status = iret;
          }
        }
      }
      return status;
    }

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.

                                          {
        return m_session;
      }

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.

    {
      std::string opt_nam, opt_val, opt_typ;
      typedef std::vector<std::string> StringV;
      for (StringV::const_iterator i=v.begin(); i!=v.end(); ++i)  {
        const std::string& id = *i;
        if ( id.length() > obj.length() )   {
          if ( obj == id.substr(0, obj.length()) )  {
            std::string n = id.substr(obj.length()+1);
            size_t idx = n.find("=");
            size_t idx2 = n.find("TYP=");
            if ( idx != std::string::npos && idx2 != std::string::npos )  {
              opt_nam = n.substr(0, idx);
              opt_val = n.substr(idx+1, idx2-2-idx);
              opt_typ = n.substr(idx2+4,1);
              std::stringstream s(opt_val);
              pool::DbOption opt(opt_nam);
              float fval;
              int   ival;
              long long int lval;
              switch(::toupper(opt_typ[0])) {
                case 'I':
                  s >> ival;
                  opt._setValue(ival);
                  pObj->setOption(opt);
                  break;
                case 'L':
                  s >> lval;
                  opt._setValue(lval);
                  pObj->setOption(opt);
                  break;
                case 'F':
                  s >> fval;
                  opt._setValue(fval);
                  pObj->setOption(opt);
                  break;
                case 'S':
                  opt._setValue(opt_val.c_str());
                  pObj->setOption(opt);
                  break;
                default:
                  break;
              }
            }
          }
        }
      }
      return pool::Success;
    }

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

    {
      switch (typ)  {
        case pool::DbOptionCallback::_DOMAIN_OPT:
          return setCallbackOptions(pObj, m_domainOpts, name);
        case pool::DbOptionCallback::_DATABASE_OPT:
          return setCallbackOptions(pObj, m_databaseOpts, name);
        case pool::DbOptionCallback::_DATABASE_ONOPEN:
          return setCallbackOptions(pObj, m_databaseOpenOpts, name);
        case pool::DbOptionCallback::_CONTAINER_OPT:
          return setCallbackOptions(pObj, m_containerOpts, name);
        case pool::DbOptionCallback::_CONTAINER_ONOPEN:
          return setCallbackOptions(pObj, m_containerOpenOpts, name);
        default:
          break;
      }
      return pool::Error;
    }

## Member Data Documentation

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_containerOpenOpts`[protected]`

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

Definition at line 59 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_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_databaseOpts`[protected]`

Buffer for database options.

Definition at line 50 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.

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

The POOL database session.

Definition at line 38 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_v22r2/GaudiPoolDb/GaudiPoolDb/PoolDbCacheSvc.h
- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiPoolDb/src/PoolDbCacheSvc.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines