| The Gaudi Framework v32r1 (f65d50dc)

CommonAuditor.h
Go to the documentation of this file.
1 #ifndef GAUDIAUD_COMMONAUDITOR_H
2 #define GAUDIAUD_COMMONAUDITOR_H
3
4 #include "GaudiKernel/Auditor.h"
5
8 class CommonAuditor : public Auditor {
9 public:
13 using Auditor::Auditor;
14
18
19 void before( StandardEventType evt, const std::string& caller ) override;
20 void before( StandardEventType evt, INamedInterface* caller ) override;
21 void before( CustomEventTypeRef evt, const std::string& caller ) override;
22 void before( CustomEventTypeRef evt, INamedInterface* caller ) override;
24
28
29 void after( StandardEventType evt, const std::string& caller, const StatusCode& sc ) override;
30 void after( StandardEventType evt, INamedInterface* caller, const StatusCode& sc ) override;
31 void after( CustomEventTypeRef evt, const std::string& caller, const StatusCode& sc ) override;
32 void after( CustomEventTypeRef evt, INamedInterface* caller, const StatusCode& sc ) override;
34
35 protected:
37 virtual void i_before( CustomEventTypeRef evt, const std::string& caller ) = 0;
39 virtual void i_after( CustomEventTypeRef evt, const std::string& caller, const StatusCode& sc ) = 0;
40
42 inline bool i_auditEventType( const std::string& evt ) {
43 // Note: there is no way to extract from a Property type the type returned by
44 // value().
45 const std::vector<std::string>& v = m_types.value();
46 // we need to return true is the list is empty or when the list does't
47 // start by "none" and the list contain the event we got.
48 return v.empty() || ( ( v[0] != "none" ) && ( find( v.begin(), v.end(), evt ) != v.end() ) );
49 }
50
51 private:
52 void deprecated_property( Gaudi::Details::PropertyBase& p ) {
53 if ( m_customTypes.size() > 0 ) {
54 if ( m_types.size() > 0 ) {
55 error() << p.name() << " is deprecated, but both " << m_customTypes.name() << " and " << m_types.name()
56 << " used." << endmsg;
57 throw GaudiException( "Property CustomEventTypes is deprecated, but both CustomEventTypes and EventTypes used",
58 this->name(), StatusCode::FAILURE );
59 } else {
60 warning() << p.name() << " " << p.documentation() << endmsg;
61 m_types = m_customTypes;
62 }
63 }
64 };
65
66 Gaudi::Property<std::vector<std::string>> m_types{
67 this, "EventTypes", {}, "list of event types to audit ([]=all, ['none']=none)"};
68 Gaudi::Property<std::vector<std::string>> m_customTypes{
69 this, "CustomEventTypes", {}, &CommonAuditor::deprecated_property, "[[deprecated]] use EventTypes instead"};
70 };
71
72 #endif // GAUDIAUD_COMMONAUDITOR_H
std::vector::empty
T empty(T... args)
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
CommonAuditor
Base class with common functionalities shared by few auditor implementations.
Definition: CommonAuditor.h:8
CommonAuditor::m_types
Gaudi::Property< std::vector< std::string > > m_types
Definition: CommonAuditor.h:66
CommonAuditor::before
void before(StandardEventType evt, const std::string &caller) override
Definition: CommonAuditor.cpp:7
std::vector::end
T end(T... args)
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:36
std::string
STL class.
CommonAuditor::i_auditEventType
bool i_auditEventType(const std::string &evt)
Check if we are requested to audit the passed event type.
Definition: CommonAuditor.h:42
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
Auditor::Auditor
Auditor(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:12
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
CommonAuditor::deprecated_property
void deprecated_property(Gaudi::Details::PropertyBase &p)
Definition: CommonAuditor.h:52
INamedInterface
IInterface compliant class extending IInterface with the name() method.
Definition: INamedInterface.h:15
std::vector< std::string >
std::vector::begin
T begin(T... args)
CommonAuditor::m_customTypes
Gaudi::Property< std::vector< std::string > > m_customTypes
Definition: CommonAuditor.h:68
Auditor::name
const std::string & name() const override
Definition: Auditor.cpp:193
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
CommonAuditor::i_before
virtual void i_before(CustomEventTypeRef evt, const std::string &caller)=0
catch all "before" method, implemented in the derived class
CommonAuditor::after
void after(StandardEventType evt, const std::string &caller, const StatusCode &sc) override
Definition: CommonAuditor.cpp:18
Auditor.h
CommonAuditor::i_after
virtual void i_after(CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc)=0
catch all "after" method, implemented in the derived class
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Details::PropertyBase::documentation
std::string documentation() const
property documentation
Definition: Property.h:38
IOTest.evt
evt
Definition: IOTest.py:94
Auditor
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:34