Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (f31105fd)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Auditor.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
13 // Include files
14 #include <Gaudi/PluginService.h>
15 #include <Gaudi/PropertyFwd.h>
17 #include <GaudiKernel/IAuditor.h>
18 #include <GaudiKernel/IProperty.h>
19 #include <GaudiKernel/IService.h>
20 #include <GaudiKernel/ISvcLocator.h> /*used by service(..)*/
22 #include <string>
23 
24 // Forward declarations
25 class IService;
26 class IMessageSvc;
27 
42 class GAUDI_API Auditor : public PropertyHolder<CommonMessaging<implements<IAuditor, IProperty>>> {
43 public:
44  using Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>;
45 
49  Auditor( std::string name, ISvcLocator* svcloc );
50 
51  Auditor( const Auditor& a ) = delete;
52  Auditor& operator=( const Auditor& rhs ) = delete;
53 
57  StatusCode sysInitialize() override;
61  StatusCode sysFinalize() override;
62 
64 
65  void before( StandardEventType, INamedInterface* ) override {}
66  void before( StandardEventType, const std::string& ) override {}
67 
68  void before( CustomEventTypeRef, INamedInterface* ) override {}
69  void before( CustomEventTypeRef, const std::string& ) override {}
70 
71  void after( StandardEventType, INamedInterface*, const StatusCode& ) override {}
72  void after( StandardEventType, const std::string&, const StatusCode& ) override {}
73 
74  void after( CustomEventTypeRef, INamedInterface*, const StatusCode& ) override {}
75  void after( CustomEventTypeRef, const std::string&, const StatusCode& ) override {}
76 
78  virtual StatusCode finalize() { return StatusCode::SUCCESS; }
79 
80  const std::string& name() const override { return m_name; }
81 
82  bool isEnabled() const override { return m_isEnabled; }
83 
88  SmartIF<ISvcLocator>& serviceLocator() const override { return m_pSvcLocator; }
89 
92  template <class T>
93  [[deprecated( "use service<T>(name, createIf) -> SmartIF<T>" )]] StatusCode service( std::string_view name, T*& svc,
94  bool createIf = false ) const {
95  auto ptr = serviceLocator()->service<T>( name, createIf );
96  if ( ptr ) {
97  svc = ptr.get();
98  svc->addRef();
99  return StatusCode::SUCCESS;
100  }
101  svc = nullptr;
102  return StatusCode::FAILURE;
103  }
104 
105  template <class T = IService>
106  SmartIF<T> service( std::string_view name, bool createIf = false ) const {
107  return serviceLocator()->service<T>( name, createIf );
108  }
109 
110 private:
112 
114 
115  Gaudi::Property<int> m_outputLevel{
116  this, "OutputLevel", MSG::NIL,
117  [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); },
118  "output level" };
119  Gaudi::Property<bool> m_isEnabled{ this, "Enable", true, "should the auditor be used or not" };
120 
121  bool m_isInitialized = false;
122  bool m_isFinalized = false;
123 };
Auditor::after
void after(StandardEventType, const std::string &, const StatusCode &) override
Definition: Auditor.h:72
Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.h:88
IService
Definition: IService.h:28
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.h:77
IService.h
std::string
STL class.
IMessageSvc
Definition: IMessageSvc.h:47
Auditor::before
void before(StandardEventType, const std::string &) override
Definition: Auditor.h:66
Auditor::after
void after(CustomEventTypeRef, const std::string &, const StatusCode &) override
Definition: Auditor.h:75
Auditor::before
void before(CustomEventTypeRef, INamedInterface *) override
Definition: Auditor.h:68
Auditor::m_name
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:111
ISvcLocator
Definition: ISvcLocator.h:46
Auditor::before
void before(StandardEventType, INamedInterface *) override
The following methods are meant to be implemented by the child class...
Definition: Auditor.h:65
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:82
Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:113
Auditor::Factory
Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)> Factory
Definition: Auditor.h:44
Auditor::after
void after(CustomEventTypeRef, INamedInterface *, const StatusCode &) override
Definition: Auditor.h:74
PluginService.h
Auditor::after
void after(StandardEventType, INamedInterface *, const StatusCode &) override
Definition: Auditor.h:71
Auditor
Definition: Auditor.h:42
StatusCode
Definition: StatusCode.h:65
Auditor::Auditor
Auditor(const Auditor &a)=delete
PropertyFwd.h
IAuditor.h
Auditor::finalize
virtual StatusCode finalize()
Definition: Auditor.h:78
SmartIF< ISvcLocator >
CommonMessaging.h
Auditor::service
SmartIF< T > service(std::string_view name, bool createIf=false) const
Definition: Auditor.h:106
INamedInterface
Definition: INamedInterface.h:25
Auditor::isEnabled
bool isEnabled() const override
Definition: Auditor.h:82
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Auditor::before
void before(CustomEventTypeRef, const std::string &) override
Definition: Auditor.h:69
MSG::NIL
@ NIL
Definition: IMessageSvc.h:25
IProperty.h
Auditor::operator=
Auditor & operator=(const Auditor &rhs)=delete
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ISvcLocator.h
Auditor::name
const std::string & name() const override
Definition: Auditor.h:80
PropertyHolder.h
Auditor::service
StatusCode service(std::string_view name, T *&svc, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
Definition: Auditor.h:93
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::Property< int >
IAuditor
Definition: IAuditor.h:27