The Gaudi Framework  master (37c0b60a)
CommonAuditor.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #ifndef GAUDIAUD_COMMONAUDITOR_H
12 #define GAUDIAUD_COMMONAUDITOR_H
13 
14 #include <GaudiKernel/Auditor.h>
15 
18 class CommonAuditor : public Auditor {
19 public:
23  using Auditor::Auditor;
24 
28 
29  void before( StandardEventType evt, const std::string& caller ) override;
30  void before( StandardEventType evt, INamedInterface* caller ) override;
31  void before( CustomEventTypeRef evt, const std::string& caller ) override;
32  void before( CustomEventTypeRef evt, INamedInterface* caller ) override;
34 
38 
39  void after( StandardEventType evt, const std::string& caller, const StatusCode& sc ) override;
40  void after( StandardEventType evt, INamedInterface* caller, const StatusCode& sc ) override;
41  void after( CustomEventTypeRef evt, const std::string& caller, const StatusCode& sc ) override;
42  void after( CustomEventTypeRef evt, INamedInterface* caller, const StatusCode& sc ) override;
44 
45 protected:
47  virtual void i_before( CustomEventTypeRef evt, std::string_view caller ) = 0;
49  virtual void i_after( CustomEventTypeRef evt, std::string_view caller, const StatusCode& sc ) = 0;
50 
52  bool i_auditEventType( std::string_view evt ) {
53  // Note: there is no way to extract from a Property type the type returned by
54  // value().
56  // we need to return true is the list is empty or when the list does't
57  // start by "none" and the list contain the event we got.
58  return v.empty() || ( ( v[0] != "none" ) && ( find( v.begin(), v.end(), evt ) != v.end() ) );
59  }
60 
61 private:
63  if ( m_customTypes.size() > 0 ) {
64  if ( m_types.size() > 0 ) {
65  error() << p.name() << " is deprecated, but both " << m_customTypes.name() << " and " << m_types.name()
66  << " used." << endmsg;
67  throw GaudiException( "Property CustomEventTypes is deprecated, but both CustomEventTypes and EventTypes used",
68  this->name(), StatusCode::FAILURE );
69  } else {
70  warning() << p.name() << " " << p.documentation() << endmsg;
72  }
73  }
74  }
75 
77  this, "EventTypes", {}, "list of event types to audit ([]=all, ['none']=none)" };
79  this, "CustomEventTypes", {}, &CommonAuditor::deprecated_property, "[[deprecated]] use EventTypes instead" };
80 };
81 
82 #endif // GAUDIAUD_COMMONAUDITOR_H
IOTest.evt
evt
Definition: IOTest.py:107
CommonAuditor
Base class with common functionalities shared by few auditor implementations.
Definition: CommonAuditor.h:18
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: PropertyBase.h:39
CommonAuditor::m_types
Gaudi::Property< std::vector< std::string > > m_types
Definition: CommonAuditor.h:76
std::string
STL class.
CommonAuditor::before
void before(StandardEventType evt, const std::string &caller) override
Definition: CommonAuditor.cpp:17
CommonAuditor::i_before
virtual void i_before(CustomEventTypeRef evt, std::string_view caller)=0
catch all "before" method, implemented in the derived class
Gaudi::Details::PropertyBase::documentation
std::string documentation() const
property documentation
Definition: PropertyBase.h:41
std::vector< std::string >
CommonAuditor::m_customTypes
Gaudi::Property< std::vector< std::string > > m_customTypes
Definition: CommonAuditor.h:78
GaudiException
Definition: GaudiException.h:31
CommonAuditor::deprecated_property
void deprecated_property(Gaudi::Details::PropertyBase &p)
Definition: CommonAuditor.h:62
Auditor::name
const std::string & name() const override
Definition: Auditor.cpp:192
CommonAuditor::after
void after(StandardEventType evt, const std::string &caller, const StatusCode &sc) override
Definition: CommonAuditor.cpp:28
Auditor
Definition: Auditor.h:43
StatusCode
Definition: StatusCode.h:65
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:237
CommonAuditor::i_auditEventType
bool i_auditEventType(std::string_view evt)
Check if we are requested to audit the passed event type.
Definition: CommonAuditor.h:52
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
INamedInterface
Definition: INamedInterface.h:25
Auditor::Auditor
Auditor(std::string name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:21
Properties.v
v
Definition: Properties.py:122
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
CommonAuditor::i_after
virtual void i_after(CustomEventTypeRef evt, std::string_view caller, const StatusCode &sc)=0
catch all "after" method, implemented in the derived class
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:37
Auditor.h