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::string & name () const override
 
bool isEnabled () const override
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
int outputLevel () const
 Retrieve the output level of current auditor. More...
 
void setOutputLevel (int level)
 Set the output level for current auditor. More...
 
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...
 
 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::string & name () const override
 
bool isEnabled () const override
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
int outputLevel () const
 Retrieve the output level of current auditor. More...
 
void setOutputLevel (int level)
 Set the output level for current auditor. More...
 
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 implements< Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
 ~implements () override=default
 Virtual destructor. More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
 ~implements () override=default
 Virtual destructor. More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. 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 Attributes

StringArrayProperty m_types
 
StringArrayProperty m_customTypes
 
- Protected Attributes inherited from implements< Interfaces >
std::atomic_ulong m_refCount = {0}
 Reference counter. More...
 

Additional Inherited Members

- Public Types inherited from Auditor
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from implements< Interfaces >
using base_class = implements< Interfaces...>
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
using base_class = implements< Interfaces...>
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 

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:241
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
const std::string & name() const override
Definition: Auditor.cpp:212
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 37 of file CommonAuditor.cpp.

38 {
39  after(toStr(evt), caller, sc);
40 }
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 33 of file CommonAuditor.cpp.

34 {
35  if (caller) after(toStr(evt), caller->name(), sc);
36 }
virtual const std::string & name() const =0
Retrieve the name of the instance.
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 ( CustomEventTypeRef  evt,
const std::string &  caller,
const StatusCode sc 
)
virtual

Definition at line 45 of file CommonAuditor.cpp.

46 {
47  if (i_auditEventType(evt)) i_after(evt, caller, sc);
48 }
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 41 of file CommonAuditor.cpp.

42 {
43  if (caller) after(evt, caller->name(), sc);
44 }
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 20 of file CommonAuditor.cpp.

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

Definition at line 16 of file CommonAuditor.cpp.

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

Definition at line 28 of file CommonAuditor.cpp.

29 {
30  if (i_auditEventType(evt)) i_before(evt, caller);
31 }
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 24 of file CommonAuditor.cpp.

25 {
26  if (caller) before(evt, caller->name());
27 }
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().
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() || (
49  (v[0] != "none") &&
50  (find(v.begin(), v.end(), evt) != v.end())
51  );
52  }
const TYPE & value() const
explicit conversion
Definition: Property.h:341
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  MsgStream log(msgSvc(), name());
12  log << MSG::WARNING << "Property CustomEventTypes is deprecated, use EventTypes instead" << endmsg;
14 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:220
bool setValue(const TYPE &value) override
implementation of PropertyWithValue::setValue
Definition: Property.h:406
StringArrayProperty m_customTypes
Definition: CommonAuditor.h:58
const TYPE & value() const
explicit conversion
Definition: Property.h:341
const std::string & name() const override
Definition: Auditor.cpp:212
StringArrayProperty m_types
Definition: CommonAuditor.h:54

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: