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