Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
34 class GAUDI_API Auditor : public PropertyHolder<CommonMessaging<implements<IAuditor, IProperty>>> {
35 public:
36  using Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>;
37 
41  Auditor( const std::string& name, ISvcLocator* svcloc );
42 
43  Auditor( const Auditor& a ) = delete;
44  Auditor& operator=( const Auditor& rhs ) = delete;
45 
49  StatusCode sysInitialize() override;
53  StatusCode sysFinalize() override;
54 
56 
57  void before( StandardEventType, INamedInterface* ) override;
58  void before( StandardEventType, const std::string& ) override;
59 
60  void before( CustomEventTypeRef, INamedInterface* ) override;
61  void before( CustomEventTypeRef, const std::string& ) override;
62 
63  void after( StandardEventType, INamedInterface*, const StatusCode& ) override;
64  void after( StandardEventType, const std::string&, const StatusCode& ) override;
65 
66  void after( CustomEventTypeRef, INamedInterface*, const StatusCode& ) override;
67  void after( CustomEventTypeRef, const std::string&, const StatusCode& ) override;
68 
69  // Obsolete methods
70 
71  void beforeInitialize( INamedInterface* ) override;
72  void afterInitialize( INamedInterface* ) override;
73 
74  void beforeReinitialize( INamedInterface* ) override;
75  void afterReinitialize( INamedInterface* ) override;
76 
77  void beforeExecute( INamedInterface* ) override;
78  void afterExecute( INamedInterface*, const StatusCode& ) override;
79 
80  void beforeFinalize( INamedInterface* ) override;
81  void afterFinalize( INamedInterface* ) override;
82 
83  void beforeBeginRun( INamedInterface* ) override;
84  void afterBeginRun( INamedInterface* ) override;
85 
86  void beforeEndRun( INamedInterface* ) override;
87  void afterEndRun( INamedInterface* ) override;
88 
89  virtual StatusCode initialize();
90  virtual StatusCode finalize();
91 
92  const std::string& name() const override;
93 
94  bool isEnabled() const override;
95 
100  SmartIF<ISvcLocator>& serviceLocator() const override;
101 
104  template <class T>
105  StatusCode service( const std::string& name, T*& svc, bool createIf = false ) const {
106  auto ptr = serviceLocator()->service<T>( name, createIf );
107  if ( ptr ) {
108  svc = ptr.get();
109  svc->addRef();
110  return StatusCode::SUCCESS;
111  }
112  svc = nullptr;
113  return StatusCode::FAILURE;
114  }
115 
116  template <class T = IService>
117  SmartIF<T> service( const std::string& name, bool createIf = false ) const {
118  return serviceLocator()->service<T>( name, createIf );
119  }
120 
126  StatusCode setProperties();
127 
128 private:
130 
132 
133  Gaudi::Property<int> m_outputLevel{
134  this, "OutputLevel", MSG::NIL,
135  [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); },
136  "output level"};
137  Gaudi::Property<bool> m_isEnabled{this, "Enable", true, "should the auditor be used or not"};
138 
139  bool m_isInitialized = false;
140  bool m_isFinalized = false;
141 };
142 
143 #endif // GAUDIKERNEL_AUDITOR_H
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:105
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:352
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::string m_name
Auditor&#39;s name for identification.
Definition: Auditor.h:129
STL class.
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:131
Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)> Factory
Definition: Auditor.h:36
General service interface definition.
Definition: IService.h:18
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
PropertyHolder & operator=(const PropertyHolder &)=delete
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:37
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
IInterface compliant class extending IInterface with the name() method.
Helper class to implement the IProperty interface.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
#define GAUDI_API
Definition: Kernel.h:71
SmartIF< T > service(const std::string &name, bool createIf=false) const
Definition: Auditor.h:117
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:34