Gaudi Framework, version v23r0 |
Home | Generated: Mon Jan 30 2012 |
an helper to share the implementation of service() among the various kernel base classes $Id: More...
#include <ServiceLocatorHelper.h>
Public Member Functions | |
ServiceLocatorHelper (ISvcLocator &svcLoc, const INamedInterface &requester) | |
ServiceLocatorHelper (ISvcLocator &svcLoc, const std::string &loggedName, const std::string &requesterName) | |
ServiceLocatorHelper (ISvcLocator &svcLoc, const std::string &requesterName) | |
ServiceLocatorHelper (ISvcLocator &svcLoc, const MsgStream &log, const std::string &requesterName) | |
StatusCode | getService (const std::string &name, bool createIf, const InterfaceID &iid, void **ppSvc) const |
StatusCode | locateService (const std::string &name, const InterfaceID &iid, void **ppSvc, bool quiet=false) const |
StatusCode | createService (const std::string &name, const InterfaceID &iid, void **ppSvc) const |
StatusCode | createService (const std::string &type, const std::string &name, const InterfaceID &iid, void **ppSvc) const |
SmartIF< IService > | service (const std::string &name, const bool quiet=false, const bool createIf=true) const |
Private Member Functions | |
std::string | threadName () const |
std::string | threadedName (const std::string &name) const |
bool | isInThread () const |
ISvcLocator * | serviceLocator () const |
MsgStream & | log () const |
const std::string & | requesterName () const |
Private Attributes | |
ISvcLocator & | m_svcLoc |
MsgStream | m_msgLog |
std::string | m_requesterName |
an helper to share the implementation of service() among the various kernel base classes $Id:
Definition at line 18 of file ServiceLocatorHelper.h.
ServiceLocatorHelper::ServiceLocatorHelper | ( | ISvcLocator & | svcLoc, |
const INamedInterface & | requester | ||
) | [inline] |
Definition at line 20 of file ServiceLocatorHelper.h.
: m_svcLoc(svcLoc), m_msgLog(SmartIF<IMessageSvc>(&svcLoc), requester.name()), //use requester msg level m_requesterName(requester.name()) { }
ServiceLocatorHelper::ServiceLocatorHelper | ( | ISvcLocator & | svcLoc, |
const std::string & | loggedName, | ||
const std::string & | requesterName | ||
) | [inline] |
Definition at line 25 of file ServiceLocatorHelper.h.
: m_svcLoc(svcLoc), m_msgLog(SmartIF<IMessageSvc>(&svcLoc), loggedName), //use requester msg level m_requesterName(requesterName) { }
ServiceLocatorHelper::ServiceLocatorHelper | ( | ISvcLocator & | svcLoc, |
const std::string & | requesterName | ||
) | [inline] |
Definition at line 32 of file ServiceLocatorHelper.h.
: m_svcLoc(svcLoc), m_msgLog(SmartIF<IMessageSvc>(&svcLoc), requesterName), //use requester msg level m_requesterName(requesterName) { }
ServiceLocatorHelper::ServiceLocatorHelper | ( | ISvcLocator & | svcLoc, |
const MsgStream & | log, | ||
const std::string & | requesterName | ||
) | [inline] |
Definition at line 38 of file ServiceLocatorHelper.h.
: m_svcLoc(svcLoc), m_msgLog(log), m_requesterName(requesterName) {}
StatusCode ServiceLocatorHelper::createService | ( | const std::string & | name, |
const InterfaceID & | iid, | ||
void ** | ppSvc | ||
) | const |
Definition at line 40 of file ServiceLocatorHelper.cpp.
{ SmartIF<IService> theSvc = service(name, false, true); if (!theSvc.isValid()) return StatusCode::FAILURE; StatusCode sc = theSvc->queryInterface(iid, ppSvc); if (!sc.isSuccess()) { *ppSvc = 0; log() << MSG::ERROR << "ServiceLocatorHelper::createService: wrong interface id " << iid << " for service " << name << endmsg; } return sc; }
StatusCode ServiceLocatorHelper::createService | ( | const std::string & | type, |
const std::string & | name, | ||
const InterfaceID & | iid, | ||
void ** | ppSvc | ||
) | const |
Definition at line 56 of file ServiceLocatorHelper.cpp.
{ return createService(type + "/" + name, iid, ppSvc); }
StatusCode ServiceLocatorHelper::getService | ( | const std::string & | name, |
bool | createIf, | ||
const InterfaceID & | iid, | ||
void ** | ppSvc | ||
) | const [inline] |
Definition at line 44 of file ServiceLocatorHelper.h.
{ return (createIf ? createService(name, iid, ppSvc) : locateService(name, iid, ppSvc, true)); }
bool ServiceLocatorHelper::isInThread | ( | ) | const [private] |
Definition at line 18 of file ServiceLocatorHelper.cpp.
{ return isGaudiThreaded(requesterName()); }
StatusCode ServiceLocatorHelper::locateService | ( | const std::string & | name, |
const InterfaceID & | iid, | ||
void ** | ppSvc, | ||
bool | quiet = false |
||
) | const |
Definition at line 23 of file ServiceLocatorHelper.cpp.
{ SmartIF<IService> theSvc = service(name, quiet, false); if (!theSvc.isValid()) return StatusCode::FAILURE; StatusCode sc = theSvc->queryInterface(iid, ppSvc); if (!sc.isSuccess()) { *ppSvc = 0; if (!quiet) log() << MSG::ERROR << "ServiceLocatorHelper::locateService: wrong interface id " << iid << " for service " << name << endmsg; } return sc; }
MsgStream& ServiceLocatorHelper::log | ( | ) | const [inline, private] |
Definition at line 74 of file ServiceLocatorHelper.h.
{ return m_msgLog; }
const std::string& ServiceLocatorHelper::requesterName | ( | ) | const [inline, private] |
Definition at line 75 of file ServiceLocatorHelper.h.
{ return m_requesterName; }
SmartIF< IService > ServiceLocatorHelper::service | ( | const std::string & | name, |
const bool | quiet = false , |
||
const bool | createIf = true |
||
) | const |
Definition at line 63 of file ServiceLocatorHelper.cpp.
{ SmartIF<IService> theSvc; if (isInThread()) { //first we look for a thread-specific version of the service theSvc = serviceLocator()->service(name + threadName(), createIf); } // if not, try to find the common, single-threaded version of the service if (!theSvc.isValid()){ theSvc = serviceLocator()->service(name, createIf); } if (theSvc.isValid()) { if (!quiet) { if (UNLIKELY(log().level() <= MSG::VERBOSE)) log() << MSG::VERBOSE << "ServiceLocatorHelper::service: found service " << name <<endmsg; } } else { // if not return an error if (!quiet) { log() << MSG::ERROR << "ServiceLocatorHelper::service: can not locate service " << name; if (isInThread()) log() << MSG::ERROR << " or " << name + threadName(); log() << MSG::ERROR << endmsg; } } return theSvc; }
ISvcLocator* ServiceLocatorHelper::serviceLocator | ( | ) | const [inline, private] |
Definition at line 73 of file ServiceLocatorHelper.h.
{ return &m_svcLoc; }
std::string ServiceLocatorHelper::threadedName | ( | const std::string & | name ) | const [private] |
Definition at line 13 of file ServiceLocatorHelper.cpp.
{ return ( isInThread() ? name + threadName() : name ); }
std::string ServiceLocatorHelper::threadName | ( | ) | const [private] |
Definition at line 8 of file ServiceLocatorHelper.cpp.
{ return getGaudiThreadIDfromName(requesterName()); }
MsgStream ServiceLocatorHelper::m_msgLog [mutable, private] |
Definition at line 77 of file ServiceLocatorHelper.h.
Definition at line 78 of file ServiceLocatorHelper.h.
ISvcLocator& ServiceLocatorHelper::m_svcLoc [private] |
Definition at line 76 of file ServiceLocatorHelper.h.