Gaudi Framework, version v23r9

Home   Generated: Thu Jul 18 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ISvcLocator.h
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/ISvcLocator.h,v 1.15 2006/12/14 12:55:44 hmd Exp $
2 #ifndef GAUDIKERNEL_ISVCLOCATOR_H
3 #define GAUDIKERNEL_ISVCLOCATOR_H 1
4 
5 // Include files
9 #include "GaudiKernel/SmartIF.h"
10 #include <string>
11 #include <list>
12 
13 // Forward class declaration
14 class IService;
15 
26 class GAUDI_API ISvcLocator: virtual public IInterface {
27 public:
30 
31 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
32 
36  virtual StatusCode getService( const Gaudi::Utils::TypeNameString& typeName,
37  IService*& svc, const bool createIf = true) {
38  SmartIF<IService> &s = service(typeName, createIf);
39  svc = s.get();
40  if (svc) {
41  svc->addRef(); // Needed to maintain the correct reference counting.
42  return StatusCode::SUCCESS;
43  }
44  return StatusCode::FAILURE;
45  }
46 
52  virtual StatusCode getService( const Gaudi::Utils::TypeNameString& typeName,
53  const InterfaceID& iid,
54  IInterface*& pinterface ) {
55  SmartIF<IService> svc = service(typeName, false);
56  if (svc.isValid()) {
57  // Service found. So now get the right interface
58  return svc->queryInterface(iid, (void**)&pinterface);
59  }
60  return StatusCode::FAILURE;
61  }
62 
68  //virtual StatusCode getService( const Gaudi::Utils::TypeNameString& name,
69  // IService*& svc,
70  // bool createIf ) = 0;
71 #endif
72 
74  virtual const std::list<IService*> &getServices() const = 0;
75 
77  virtual bool existsService(const std::string& name) const = 0;
78 
79 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
80 
81  template <class T>
82  StatusCode service( const Gaudi::Utils::TypeNameString& name, T*& svc, bool createIf = true ) {
83  if( createIf ) {
84  IService* s;
85  StatusCode sc = getService( name, s, true);
86  if ( !sc.isSuccess() ) return sc; // Must check if initialization was OK!
87  }
88  return getService( name, T::interfaceID(), (IInterface*&)svc );
89  }
90 
92  template <class T>
93  StatusCode service( const std::string& type, const std::string& name,
94  T*& svc, bool createIf = true ) {
95  return service(type + "/" + name, svc, createIf);
96  }
97 #endif
98 
100  virtual SmartIF<IService> &service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf = true) = 0;
101 
103  template <typename T>
104  inline SmartIF<T> service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf = true) {
105  return SmartIF<T>(service(typeName, createIf));
106  }
107 
108 };
109 
110 
111 #endif // GAUDI_ISVCLOCATOR_H

Generated at Thu Jul 18 2013 12:18:03 for Gaudi Framework, version v23r9 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004