| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# ServiceLocatorHelper.h

Go to the documentation of this file.

    00001 #ifndef GAUDIKERNEL_SERVICELOCATORHELPER_H
    00002 #define GAUDIKERNEL_SERVICELOCATORHELPER_H
    00003
    00004 #include <string>
    00005 #include <GaudiKernel/StatusCode.h>
    00006 class ISvcLocator;
    00007 class InterfaceID;
    00008 class MsgStream;
    00009
    00015 class ServiceLocatorHelper {
    00016 public:
    00017   ServiceLocatorHelper(ISvcLocator& svcLoc,
    00018                  MsgStream& log, //use requestor msg level
    00019                  const std::string& requestorName):
    00020     m_svcLoc(svcLoc), m_msgLog(log), m_requestorName(requestorName) {}
    00021
    00022   StatusCode getService(const std::string& name,
    00023                         bool createIf,
    00024                         const InterfaceID& iid,
    00025                         void** ppSvc) const {
    00026     return (createIf ?
    00027             createService(name, iid, ppSvc) :
    00028             locateService(name, iid, ppSvc, true));
    00029   }
    00030
    00031   StatusCode locateService(const std::string& name,
    00032                            const InterfaceID& iid,
    00033                            void** ppSvc,
    00034                            bool quiet=false) const;
    00035
    00036   StatusCode createService(const std::string& name,
    00037                            const InterfaceID& iid,
    00038                            void** ppSvc) const;
    00039
    00040   StatusCode createService(const std::string& type,
    00041                            const std::string& name,
    00042                            const InterfaceID& iid,
    00043                            void** ppSvc) const;
    00044 private:
    00045   std::string threadName() const;
    00046   std::string threadedName(const std::string& name) const;
    00047   bool isInThread() const;
    00048   ISvcLocator* serviceLocator() const { return &m_svcLoc; }
    00049   MsgStream& log() const { return m_msgLog; }
    00050   const std::string& requestorName() const { return m_requestorName; }
    00051   ISvcLocator& m_svcLoc;
    00052   MsgStream& m_msgLog;
    00053   std::string m_requestorName;
    00054 };
    00055 #endif