The Gaudi Framework  master (f5098d57)
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 <Gaudi/IAuditor.h>
14 #include <Gaudi/PluginService.h>
15 #include <Gaudi/PropertyFwd.h>
17 #include <GaudiKernel/IProperty.h>
18 #include <GaudiKernel/IService.h>
19 #include <GaudiKernel/ISvcLocator.h> /*used by service(..)*/
21 #include <string>
22 
23 namespace Gaudi {
24 
33  class GAUDI_API Auditor : public PropertyHolder<CommonMessaging<implements<IAuditor, IProperty>>> {
34  public:
35  using Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>;
36 
37  Auditor( std::string name, ISvcLocator* svcloc ) : m_name( std::move( name ) ), m_pSvcLocator( svcloc ){};
38  Auditor( const Auditor& a ) = delete;
39  Auditor& operator=( const Auditor& rhs ) = delete;
40 
41  StatusCode sysInitialize() override;
42  StatusCode sysFinalize() override;
43 
44  void before( std::string const&, std::string const&, EventContext const& ) override {}
45  void after( std::string const&, std::string const&, EventContext const&,
46  StatusCode const& = StatusCode::SUCCESS ) override {}
47 
49  virtual StatusCode finalize() { return StatusCode::SUCCESS; }
50 
51  const std::string& name() const override { return m_name; }
52  bool isEnabled() const override { return m_isEnabled; }
53 
59  SmartIF<ISvcLocator>& serviceLocator() const override { return m_pSvcLocator; }
60 
62  template <class T = IService>
63  SmartIF<T> service( std::string_view name, bool createIf = false ) const {
64  return serviceLocator()->service<T>( name, createIf );
65  }
66 
67  private:
68  std::string m_name;
69 
71 
72  Gaudi::Property<int> m_outputLevel{
73  this, "OutputLevel", MSG::NIL,
74  [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); },
75  "output level" };
76  Gaudi::Property<bool> m_isEnabled{ this, "Enable", true, "should the auditor be used or not" };
77 
78  bool m_isInitialized = false;
79  bool m_isFinalized = false;
80  };
81 
82 } // namespace Gaudi
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
IService.h
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
Gaudi::IAuditor
The IAuditor is the interface implemented by the Auditor base class.
Definition: IAuditor.h:26
Gaudi::Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Auditor's name for identification.
Definition: Auditor.h:70
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::Auditor::after
void after(std::string const &, std::string const &, EventContext const &, StatusCode const &=StatusCode::SUCCESS) override
Definition: Auditor.h:45
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:77
Gaudi::Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.h:59
PluginService.h
StatusCode
Definition: StatusCode.h:65
Gaudi::Auditor::Auditor
Auditor(std::string name, ISvcLocator *svcloc)
Definition: Auditor.h:37
Gaudi::Auditor::name
const std::string & name() const override
Definition: Auditor.h:51
PropertyFwd.h
IAuditor.h
Gaudi::Auditor::finalize
virtual StatusCode finalize()
Definition: Auditor.h:49
SmartIF< ISvcLocator >
CommonMessaging.h
Gaudi::Auditor::Factory
Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)> Factory
Definition: Auditor.h:35
Gaudi::Auditor::before
void before(std::string const &, std::string const &, EventContext const &) override
Definition: Auditor.h:44
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::Auditor::Auditor
Auditor(const Auditor &a)=delete
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Gaudi::Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.h:48
MSG::NIL
@ NIL
Definition: IMessageSvc.h:25
EventContext
Definition: EventContext.h:34
IProperty.h
Gaudi::Auditor::isEnabled
bool isEnabled() const override
Definition: Auditor.h:52
Gaudi::Auditor
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:33
ISvcLocator.h
PropertyHolder.h
Gaudi::Auditor::service
SmartIF< T > service(std::string_view name, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
Definition: Auditor.h:63
Gaudi::Auditor::m_name
std::string m_name
Definition: Auditor.h:68
Gaudi::Auditor::operator=
Auditor & operator=(const Auditor &rhs)=delete
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::Property< int >