CommonAuditor Class Referenceabstract

Base class with common functionalities shared by few auditor implementations. More...

#include <src/CommonAuditor.h>

Inheritance diagram for CommonAuditor:
Collaboration diagram for CommonAuditor:

Public Member Functions

 CommonAuditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
virtual ~CommonAuditor ()=default
 Destructor. More...
 
"before" Auditor hooks

The default behavior is to fall back on the version accepting 2 strings, which must be implemented in the derived class.

virtual void before (StandardEventType evt, const std::string &caller)
 
virtual void before (StandardEventType evt, INamedInterface *caller)
 
virtual void before (CustomEventTypeRef evt, const std::string &caller)
 
virtual void before (CustomEventTypeRef evt, INamedInterface *caller)
 
"after" Auditor hooks

The default behavior is to fall back on the version accepting 2 strings, which must be implemented in the derived class.

virtual void after (StandardEventType evt, const std::string &caller, const StatusCode &sc)
 
virtual void after (StandardEventType evt, INamedInterface *caller, const StatusCode &sc)
 
virtual void after (CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc)
 
virtual void after (CustomEventTypeRef evt, INamedInterface *caller, const StatusCode &sc)
 
- Public Member Functions inherited from Auditor
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 ~Auditor () override=default
 Destructor. More...
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize () override
 Finalization method invoked by the framework. More...
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void beforeInitialize (INamedInterface *) override
 
void afterInitialize (INamedInterface *) override
 
void beforeReinitialize (INamedInterface *) override
 
void afterReinitialize (INamedInterface *) override
 
void beforeExecute (INamedInterface *) override
 
void afterExecute (INamedInterface *, const StatusCode &) override
 
void beforeFinalize (INamedInterface *) override
 
void afterFinalize (INamedInterface *) override
 
void beforeBeginRun (INamedInterface *) override
 
void afterBeginRun (INamedInterface *) override
 
void beforeEndRun (INamedInterface *) override
 
void afterEndRun (INamedInterface *) override
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
const std::stringname () const override
 
bool isEnabled () const override
 
SmartIF< ISvcLocator > & serviceLocator () const
 The standard service locator. More...
 
template<class T >
StatusCode service (const std::string &name, T *&svc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T = IService>
SmartIF< T > service (const std::string &name, bool createIf=false) const
 
StatusCode setProperty (const Property &p) override
 Set a value of a property of an auditor. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Get the value of a property. More...
 
const PropertygetProperty (const std::string &name) const override
 Get the property by name. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const override
 Get all properties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Protected Member Functions

virtual void i_before (CustomEventTypeRef evt, const std::string &caller)=0
 catch all "before" method, implemented in the derived class More...
 
virtual void i_after (CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc)=0
 catch all "after" method, implemented in the derived class More...
 
bool i_auditEventType (const std::string &evt)
 Check if we are requested to audit the passed event type. More...
 
void i_updateCustomTypes (Property &)
 Update handler for the obsolete property CustomEventTypes. More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

StringArrayProperty m_types
 
StringArrayProperty m_customTypes
 

Additional Inherited Members

- Public Types inherited from Auditor
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using base_class = CommonMessaging
 

Detailed Description

Base class with common functionalities shared by few auditor implementations.

Author
Marco Clemencic

Definition at line 5 of file CommonAuditor.h.

Constructor & Destructor Documentation

CommonAuditor::CommonAuditor ( const std::string name,
ISvcLocator svcloc 
)

Constructor.

Parameters
nameThe algorithm object's name
svclocA pointer to a service location service

Definition at line 3 of file CommonAuditor.cpp.

3  : Auditor(name, svcloc) {
4  declareProperty("EventTypes", m_types,
5  "List of event types to audit ([]=all, ['none']=none)");
6  declareProperty("CustomEventTypes", m_customTypes,
7  "OBSOLETE, use EventTypes instead")->declareUpdateHandler(&CommonAuditor::i_updateCustomTypes, this);
8 }
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Auditor.h:232
void i_updateCustomTypes(Property &)
Update handler for the obsolete property CustomEventTypes.
Auditor(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:12
StringArrayProperty m_customTypes
Definition: CommonAuditor.h:58
StringArrayProperty m_types
Definition: CommonAuditor.h:54
virtual CommonAuditor::~CommonAuditor ( )
virtualdefault

Destructor.

Member Function Documentation

void CommonAuditor::after ( StandardEventType  evt,
const std::string caller,
const StatusCode sc 
)
virtual

Definition at line 36 of file CommonAuditor.cpp.

37 {
38  after(toStr(evt), caller, sc);
39 }
const char * toStr(IAuditor::StandardEventType e)
Simple mapping function from IAuditor::StandardEventType to string.
Definition: IAuditor.h:106
virtual void after(StandardEventType evt, const std::string &caller, const StatusCode &sc)
void CommonAuditor::after ( StandardEventType  evt,
INamedInterface caller,
const StatusCode sc 
)
virtual

Definition at line 32 of file CommonAuditor.cpp.

33 {
34  if (caller) after(toStr(evt), caller->name(), sc);
35 }
const char * toStr(IAuditor::StandardEventType e)
Simple mapping function from IAuditor::StandardEventType to string.
Definition: IAuditor.h:106
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual void after(StandardEventType evt, const std::string &caller, const StatusCode &sc)
void CommonAuditor::after ( CustomEventTypeRef  evt,
const std::string caller,
const StatusCode sc 
)
virtual

Definition at line 44 of file CommonAuditor.cpp.

45 {
46  if (i_auditEventType(evt)) i_after(evt, caller, sc);
47 }
bool i_auditEventType(const std::string &evt)
Check if we are requested to audit the passed event type.
Definition: CommonAuditor.h:42
virtual void i_after(CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc)=0
catch all "after" method, implemented in the derived class
void CommonAuditor::after ( CustomEventTypeRef  evt,
INamedInterface caller,
const StatusCode sc 
)
virtual

Definition at line 40 of file CommonAuditor.cpp.

41 {
42  if (caller) after(evt, caller->name(), sc);
43 }
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual void after(StandardEventType evt, const std::string &caller, const StatusCode &sc)
void CommonAuditor::before ( StandardEventType  evt,
const std::string caller 
)
virtual

Definition at line 19 of file CommonAuditor.cpp.

20 {
21  before(toStr(evt), caller);
22 }
const char * toStr(IAuditor::StandardEventType e)
Simple mapping function from IAuditor::StandardEventType to string.
Definition: IAuditor.h:106
virtual void before(StandardEventType evt, const std::string &caller)
void CommonAuditor::before ( StandardEventType  evt,
INamedInterface caller 
)
virtual

Definition at line 15 of file CommonAuditor.cpp.

16 {
17  if (caller) before(toStr(evt), caller->name());
18 }
const char * toStr(IAuditor::StandardEventType e)
Simple mapping function from IAuditor::StandardEventType to string.
Definition: IAuditor.h:106
virtual void before(StandardEventType evt, const std::string &caller)
virtual const std::string & name() const =0
Retrieve the name of the instance.
void CommonAuditor::before ( CustomEventTypeRef  evt,
const std::string caller 
)
virtual

Definition at line 27 of file CommonAuditor.cpp.

28 {
29  if (i_auditEventType(evt)) i_before(evt, caller);
30 }
bool i_auditEventType(const std::string &evt)
Check if we are requested to audit the passed event type.
Definition: CommonAuditor.h:42
virtual void i_before(CustomEventTypeRef evt, const std::string &caller)=0
catch all "before" method, implemented in the derived class
void CommonAuditor::before ( CustomEventTypeRef  evt,
INamedInterface caller 
)
virtual

Definition at line 23 of file CommonAuditor.cpp.

24 {
25  if (caller) before(evt, caller->name());
26 }
virtual void before(StandardEventType evt, const std::string &caller)
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual void CommonAuditor::i_after ( CustomEventTypeRef  evt,
const std::string caller,
const StatusCode sc 
)
protectedpure virtual

catch all "after" method, implemented in the derived class

Implemented in ChronoAuditor, MemoryAuditor, and NameAuditor.

bool CommonAuditor::i_auditEventType ( const std::string evt)
inlineprotected

Check if we are requested to audit the passed event type.

Definition at line 42 of file CommonAuditor.h.

42  {
43  // Note: there is no way to extract from a Property type the type returned by
44  // 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() || (
49  (v[0] != "none") &&
50  (find(v.begin(), v.end(), evt) != v.end())
51  );
52  }
T empty(T...args)
T end(T...args)
const TYPE & value() const
explicit conversion
Definition: Property.h:341
T find(T...args)
T begin(T...args)
StringArrayProperty m_types
Definition: CommonAuditor.h:54
virtual void CommonAuditor::i_before ( CustomEventTypeRef  evt,
const std::string caller 
)
protectedpure virtual

catch all "before" method, implemented in the derived class

Implemented in ChronoAuditor, MemStatAuditor, MemoryAuditor, and NameAuditor.

void CommonAuditor::i_updateCustomTypes ( Property )
protected

Update handler for the obsolete property CustomEventTypes.

Definition at line 10 of file CommonAuditor.cpp.

10  {
11  warning() << "Property CustomEventTypes is deprecated, use EventTypes instead" << endmsg;
13 }
bool setValue(const TYPE &value) override
implementation of PropertyWithValue::setValue
Definition: Property.h:406
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StringArrayProperty m_customTypes
Definition: CommonAuditor.h:58
const TYPE & value() const
explicit conversion
Definition: Property.h:341
StringArrayProperty m_types
Definition: CommonAuditor.h:54
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Data Documentation

StringArrayProperty CommonAuditor::m_customTypes
protected

Definition at line 58 of file CommonAuditor.h.

StringArrayProperty CommonAuditor::m_types
protected

Definition at line 54 of file CommonAuditor.h.


The documentation for this class was generated from the following files: