The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
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>
19#include <GaudiKernel/ISvcLocator.h> /*used by service(..)*/
21#include <string>
22
23namespace 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
50
51 const std::string& name() const override { return m_name; }
52 bool isEnabled() const override { return m_isEnabled; }
53
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
73 this, "OutputLevel", MSG::NIL,
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
#define GAUDI_API
Definition Kernel.h:49
This class represents an entry point to all the event specific data.
void before(std::string const &, std::string const &, EventContext const &) override
Definition Auditor.h:44
Gaudi::Property< int > m_outputLevel
Pointer to service locator service.
Definition Auditor.h:72
bool m_isFinalized
Auditor has been initialized flag.
Definition Auditor.h:79
void after(std::string const &, std::string const &, EventContext const &, StatusCode const &=StatusCode::SUCCESS) override
Definition Auditor.h:45
SmartIF< ISvcLocator > m_pSvcLocator
Auditor's name for identification.
Definition Auditor.h:70
const std::string & name() const override
Definition Auditor.h:51
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
bool m_isInitialized
Definition Auditor.h:78
virtual StatusCode initialize()
Definition Auditor.h:48
Gaudi::Property< bool > m_isEnabled
Definition Auditor.h:76
Auditor(std::string name, ISvcLocator *svcloc)
Definition Auditor.h:37
Auditor(const Auditor &a)=delete
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition Auditor.h:59
Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)> Factory
Definition Auditor.h:35
std::string m_name
Definition Auditor.h:68
StatusCode sysFinalize() override
Definition Auditor.cpp:53
Auditor & operator=(const Auditor &rhs)=delete
bool isEnabled() const override
Definition Auditor.h:52
virtual StatusCode finalize()
Definition Auditor.h:49
StatusCode sysInitialize() override
Definition Auditor.cpp:16
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
The IAuditor is the interface implemented by the Auditor base class.
Definition IAuditor.h:26
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
@ NIL
Definition IMessageSvc.h:22
STL namespace.