The Gaudi Framework  v30r3 (a5ef0a68)
Auditor.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_AUDITOR_H
2 #define GAUDIKERNEL_AUDITOR_H
3 
4 // Include files
6 #include "GaudiKernel/IAuditor.h"
8 #include "GaudiKernel/IService.h"
9 #include "GaudiKernel/ISvcLocator.h" /*used by service(..)*/
12 #include <Gaudi/PluginService.h>
13 #include <string>
14 #include <vector>
15 
16 // Forward declarations
17 class IService;
18 class IMessageSvc;
19 class Algorithm;
20 
35 class GAUDI_API Auditor : public PropertyHolder<CommonMessaging<implements<IAuditor, IProperty>>>
36 {
37 public:
38  using Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>;
39 
43  Auditor( const std::string& name, ISvcLocator* svcloc );
44 
45  Auditor( const Auditor& a ) = delete;
46  Auditor& operator=( const Auditor& rhs ) = delete;
47 
51  StatusCode sysInitialize() override;
55  StatusCode sysFinalize() override;
56 
58 
59  void before( StandardEventType, INamedInterface* ) override;
60  void before( StandardEventType, const std::string& ) override;
61 
62  void before( CustomEventTypeRef, INamedInterface* ) override;
63  void before( CustomEventTypeRef, const std::string& ) override;
64 
65  void after( StandardEventType, INamedInterface*, const StatusCode& ) override;
66  void after( StandardEventType, const std::string&, const StatusCode& ) override;
67 
68  void after( CustomEventTypeRef, INamedInterface*, const StatusCode& ) override;
69  void after( CustomEventTypeRef, const std::string&, const StatusCode& ) override;
70 
71  // Obsolete methods
72 
73  void beforeInitialize( INamedInterface* ) override;
74  void afterInitialize( INamedInterface* ) override;
75 
76  void beforeReinitialize( INamedInterface* ) override;
77  void afterReinitialize( INamedInterface* ) override;
78 
79  void beforeExecute( INamedInterface* ) override;
80  void afterExecute( INamedInterface*, const StatusCode& ) override;
81 
82  void beforeFinalize( INamedInterface* ) override;
83  void afterFinalize( INamedInterface* ) override;
84 
85  void beforeBeginRun( INamedInterface* ) override;
86  void afterBeginRun( INamedInterface* ) override;
87 
88  void beforeEndRun( INamedInterface* ) override;
89  void afterEndRun( INamedInterface* ) override;
90 
91  virtual StatusCode initialize();
92  virtual StatusCode finalize();
93 
94  const std::string& name() const override;
95 
96  bool isEnabled() const override;
97 
102  SmartIF<ISvcLocator>& serviceLocator() const override;
103 
106  template <class T>
107  StatusCode service( const std::string& name, T*& svc, bool createIf = false ) const
108  {
109  auto ptr = serviceLocator()->service<T>( name, createIf );
110  if ( ptr ) {
111  svc = ptr.get();
112  svc->addRef();
113  return StatusCode::SUCCESS;
114  }
115  svc = nullptr;
116  return StatusCode::FAILURE;
117  }
118 
119  template <class T = IService>
120  SmartIF<T> service( const std::string& name, bool createIf = false ) const
121  {
122  return serviceLocator()->service<T>( name, createIf );
123  }
124 
130  StatusCode setProperties();
131 
132 private:
134 
136 
137  Gaudi::Property<int> m_outputLevel{this, "OutputLevel", MSG::NIL, "output level"};
138  Gaudi::Property<bool> m_isEnabled{this, "Enable", true, "should the auditor be used or not"};
139 
140  bool m_isInitialized = false;
141  bool m_isFinalized = false;
142 };
143 
144 #endif // GAUDIKERNEL_AUDITOR_H
constexpr static const auto FAILURE
Definition: StatusCode.h:88
StatusCode service(const std::string &name, T *&svc, bool createIf=false) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Auditor.h:107
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Implementation of property with value of concrete type.
Definition: Property.h:381
std::string m_name
Auditor&#39;s name for identification.
Definition: Auditor.h:133
STL class.
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:135
Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)> Factory
Definition: Auditor.h:38
General service interface definition.
Definition: IService.h:18
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
PropertyHolder & operator=(const PropertyHolder &)=delete
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
IInterface compliant class extending IInterface with the name() method.
Helper class to implement the IProperty interface.
#define GAUDI_API
Definition: Kernel.h:104
SmartIF< T > service(const std::string &name, bool createIf=false) const
Definition: Auditor.h:120
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:35