ATLAS Offline Software
AsgService.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #ifndef ASGSERVICES_ASGSERVICE_H
9 #define ASGSERVICES_ASGSERVICE_H
10 
12 
13 #ifdef XAOD_STANDALONE
15 #include "AsgTools/AsgComponent.h"
16 #else
18 #endif
19 
20 #include <vector>
21 #include <utility>
22 
23 class ISvcLocator;
24 
25 namespace asg
26 {
27  // Declare the type name of AsgService's base class
28 #ifndef XAOD_STANDALONE
29  typedef ::AthService AsgServiceBase;
30 #else
31  typedef AsgComponent AsgServiceBase;
32 #endif
33 
40 
41  class AsgService : public virtual IAsgService,
42  public AsgServiceBase
43  {
44  public:
45  AsgService (const std::string& name,
46  ISvcLocator* pSvcLocator);
47 
48 
51  virtual StatusCode initialize ();
52  virtual StatusCode finalize ();
54 
56  virtual void print() const;
57 
59  template<typename T> void declareServiceInterface ();
60 
61 
62 #ifndef XAOD_STANDALONE
63  virtual StatusCode queryInterface (const InterfaceID& riid, void **ppvi);
65 
67  private:
68  std::vector<std::pair<const InterfaceID& (*)(),void *(*)(AsgService*)>> m_interfaces;
69 #endif
70 
71  }; // class AsgService
72 
73 
74 
75  template<typename T>
77  {
78 #ifndef XAOD_STANDALONE
79  m_interfaces.emplace_back (T::interfaceID, [] (AsgService *self) -> void* {return dynamic_cast<T*>(self);});
80 #endif
81  }
82 
83 } // namespace asg
84 
85 #endif // ASGSERVICES_ASGSERVICE_H
asg::AsgService::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvi)
query interface for gaudi
Definition: AsgService.cxx:58
asg::AsgService::finalize
virtual StatusCode finalize()
Definition: AsgService.cxx:41
asg::IAsgService
Base class for the dual-use service interface classes.
Definition: IAsgService.h:35
asg
Definition: DataHandleTestTool.h:28
asg::AsgService::m_interfaces
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
list of interfaces we have
Definition: AsgService.h:68
asg::AsgService::print
virtual void print() const
Print the state of the service.
Definition: AsgService.cxx:48
AsgMessaging.h
IAsgService.h
asg::AsgService
Base class for the dual-use service implementation classes.
Definition: AsgService.h:43
asg::AsgService::initialize
virtual StatusCode initialize()
set up/tear down functions
Definition: AsgService.cxx:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthService
Definition: AthService.h:32
asg::AsgService::declareServiceInterface
void declareServiceInterface()
add the given interface to the list of interfaces
Definition: AsgService.h:76
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
AsgComponent.h
AthService.h
asg::AsgService::AsgService
AsgService(const std::string &name, ISvcLocator *pSvcLocator)
Definition: AsgService.cxx:19
asg::AsgServiceBase
::AthService AsgServiceBase
Definition: AsgService.h:29