All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ServiceLocatorHelper Class Reference

an helper to share the implementation of service() among the various kernel base classes $Id: More...

#include </scratch/z5/marcocle/lhcb-release/419/GAUDI/GAUDI_v26r1/InstallArea/x86_64-slc6-gcc48-opt/include/GaudiKernel/ServiceLocatorHelper.h>

Collaboration diagram for ServiceLocatorHelper:

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< IServiceservice (const std::string &name, const bool quiet=false, const bool createIf=true) const
 
 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< IServiceservice (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
 
ISvcLocatorserviceLocator () const
 
MsgStreamlog () const
 
const std::string & requesterName () const
 
std::string threadName () const
 
std::string threadedName (const std::string &name) const
 
bool isInThread () const
 
ISvcLocatorserviceLocator () const
 
MsgStreamlog () const
 
const std::string & requesterName () const
 

Private Attributes

ISvcLocatorm_svcLoc
 
MsgStream m_msgLog
 
std::string m_requesterName
 

Detailed Description

an helper to share the implementation of service() among the various kernel base classes $Id:

Definition at line 18 of file ServiceLocatorHelper.h.

Constructor & Destructor Documentation

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
}
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
}
ServiceLocatorHelper::ServiceLocatorHelper ( ISvcLocator svcLoc,
const MsgStream log,
const std::string &  requesterName 
)
inline

Definition at line 38 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
}
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
}
ServiceLocatorHelper::ServiceLocatorHelper ( ISvcLocator svcLoc,
const MsgStream log,
const std::string &  requesterName 
)
inline

Definition at line 38 of file ServiceLocatorHelper.h.

Member Function Documentation

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;
<< "ServiceLocatorHelper::createService: wrong interface id "
<< iid << " for service " << name << endmsg;
}
return sc;
}
StatusCode ServiceLocatorHelper::createService ( const std::string &  name,
const InterfaceID iid,
void **  ppSvc 
) const
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::createService ( const std::string &  type,
const std::string &  name,
const InterfaceID iid,
void **  ppSvc 
) const
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));
}
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.

bool ServiceLocatorHelper::isInThread ( ) const
private
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;
}
StatusCode ServiceLocatorHelper::locateService ( const std::string &  name,
const InterfaceID iid,
void **  ppSvc,
bool  quiet = false 
) const
MsgStream& ServiceLocatorHelper::log ( ) const
inlineprivate

Definition at line 74 of file ServiceLocatorHelper.h.

{ return m_msgLog; }
MsgStream& ServiceLocatorHelper::log ( ) const
inlineprivate

Definition at line 74 of file ServiceLocatorHelper.h.

{ return m_msgLog; }
const std::string& ServiceLocatorHelper::requesterName ( ) const
inlineprivate

Definition at line 75 of file ServiceLocatorHelper.h.

{ return m_requesterName; }
const std::string& ServiceLocatorHelper::requesterName ( ) const
inlineprivate

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

{
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) {
<< "ServiceLocatorHelper::service: found service " << name <<endmsg;
}
} else {
// if not return an error
if (!quiet) {
<< "ServiceLocatorHelper::service: can not locate service "
<< name;
if (isInThread()) log() << MSG::ERROR << " or " << name + threadName();
}
}
return theSvc;
}
ISvcLocator* ServiceLocatorHelper::serviceLocator ( ) const
inlineprivate

Definition at line 73 of file ServiceLocatorHelper.h.

{ return &m_svcLoc; }
ISvcLocator* ServiceLocatorHelper::serviceLocator ( ) const
inlineprivate

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::threadedName ( const std::string &  name) const
private
std::string ServiceLocatorHelper::threadName ( ) const
private

Definition at line 8 of file ServiceLocatorHelper.cpp.

std::string ServiceLocatorHelper::threadName ( ) const
private

Member Data Documentation

MsgStream ServiceLocatorHelper::m_msgLog
mutableprivate

Definition at line 77 of file ServiceLocatorHelper.h.

std::string ServiceLocatorHelper::m_requesterName
private

Definition at line 78 of file ServiceLocatorHelper.h.

ISvcLocator & ServiceLocatorHelper::m_svcLoc
private

Definition at line 76 of file ServiceLocatorHelper.h.


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