The Gaudi Framework  master (594c33fa)
CommonAuditor Class Referenceabstract

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

#include </builds/gaudi/Gaudi/GaudiAud/src/CommonAuditor.h>

Inheritance diagram for CommonAuditor:
Collaboration diagram for CommonAuditor:

Public Member Functions

 Auditor (std::string name, ISvcLocator *svcloc)
 Constructor. More...
 
 Auditor (const Auditor &a)=delete
 Constructor. 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.

void before (StandardEventType evt, const std::string &caller) override
 
void before (StandardEventType evt, INamedInterface *caller) override
 
void before (CustomEventTypeRef evt, const std::string &caller) override
 
void before (CustomEventTypeRef evt, INamedInterface *caller) override
 
- Public Member Functions inherited from Auditor
 Auditor (std::string name, ISvcLocator *svcloc)
 Constructor. More...
 
 Auditor (const Auditor &a)=delete
 
Auditoroperator= (const Auditor &rhs)=delete
 
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
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
const std::stringname () const override
 
bool isEnabled () const override
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
template<class T >
StatusCode service (std::string_view 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 (std::string_view name, bool createIf=false) const
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

"after" Auditor hooks

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

Gaudi::Property< std::vector< std::string > > m_types
 
Gaudi::Property< std::vector< std::string > > m_customTypes
 
void after (StandardEventType evt, const std::string &caller, const StatusCode &sc) override
 
void after (StandardEventType evt, INamedInterface *caller, const StatusCode &sc) override
 
void after (CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc) override
 
void after (CustomEventTypeRef evt, INamedInterface *caller, const StatusCode &sc) override
 
virtual void i_before (CustomEventTypeRef evt, std::string_view caller)=0
 catch all "before" method, implemented in the derived class More...
 
virtual void i_after (CustomEventTypeRef evt, std::string_view caller, const StatusCode &sc)=0
 catch all "after" method, implemented in the derived class More...
 
bool i_auditEventType (std::string_view evt)
 Check if we are requested to audit the passed event type. More...
 
void deprecated_property (Gaudi::Details::PropertyBase &p)
 

Additional Inherited Members

- Public Types inherited from Auditor
using Factory = Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using base_class = CommonMessaging
 
- Protected Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Detailed Description

Base class with common functionalities shared by few auditor implementations.

Author
Marco Clemencic

Definition at line 18 of file CommonAuditor.h.

Member Function Documentation

◆ after() [1/4]

void CommonAuditor::after ( CustomEventTypeRef  evt,
const std::string caller,
const StatusCode sc 
)
override

Definition at line 34 of file CommonAuditor.cpp.

34  {
35  if ( i_auditEventType( evt ) ) i_after( evt, caller, sc );
36 }

◆ after() [2/4]

void CommonAuditor::after ( CustomEventTypeRef  evt,
INamedInterface caller,
const StatusCode sc 
)
override

Definition at line 31 of file CommonAuditor.cpp.

31  {
32  if ( caller ) after( evt, caller->name(), sc );
33 }

◆ after() [3/4]

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

Definition at line 28 of file CommonAuditor.cpp.

28  {
29  after( toStr( evt ), caller, sc );
30 }

◆ after() [4/4]

void CommonAuditor::after ( StandardEventType  evt,
INamedInterface caller,
const StatusCode sc 
)
override

Definition at line 25 of file CommonAuditor.cpp.

25  {
26  if ( caller ) after( toStr( evt ), caller->name(), sc );
27 }

◆ Auditor() [1/2]

Auditor::Auditor
delete

Constructor.

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

◆ Auditor() [2/2]

Auditor::Auditor

Constructor.

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

Definition at line 51 of file Auditor.cpp.

22  : m_name( std::move( name ) ), m_pSvcLocator( pSvcLocator ) {}

◆ before() [1/4]

void CommonAuditor::before ( CustomEventTypeRef  evt,
const std::string caller 
)
override

Definition at line 21 of file CommonAuditor.cpp.

21  {
22  if ( i_auditEventType( evt ) ) i_before( evt, caller );
23 }

◆ before() [2/4]

void CommonAuditor::before ( CustomEventTypeRef  evt,
INamedInterface caller 
)
override

Definition at line 18 of file CommonAuditor.cpp.

18  {
19  if ( caller ) before( evt, caller->name() );
20 }

◆ before() [3/4]

void CommonAuditor::before ( StandardEventType  evt,
const std::string caller 
)
override

Definition at line 17 of file CommonAuditor.cpp.

17 { before( toStr( evt ), caller ); }

◆ before() [4/4]

void CommonAuditor::before ( StandardEventType  evt,
INamedInterface caller 
)
override

Definition at line 14 of file CommonAuditor.cpp.

14  {
15  if ( caller ) before( toStr( evt ), caller->name() );
16 }

◆ deprecated_property()

void CommonAuditor::deprecated_property ( Gaudi::Details::PropertyBase p)
inlineprivate

Definition at line 62 of file CommonAuditor.h.

62  {
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  };

◆ i_after()

virtual void CommonAuditor::i_after ( CustomEventTypeRef  evt,
std::string_view  caller,
const StatusCode sc 
)
protectedpure virtual

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

Implemented in ChronoAuditor, MemoryAuditor, MemStatAuditor, and NameAuditor.

◆ i_auditEventType()

bool CommonAuditor::i_auditEventType ( std::string_view  evt)
inlineprotected

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

Definition at line 52 of file CommonAuditor.h.

52  {
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  }

◆ i_before()

virtual void CommonAuditor::i_before ( CustomEventTypeRef  evt,
std::string_view  caller 
)
protectedpure virtual

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

Implemented in MemStatAuditor, ChronoAuditor, MemoryAuditor, and NameAuditor.

Member Data Documentation

◆ m_customTypes

Gaudi::Property<std::vector<std::string> > CommonAuditor::m_customTypes
private
Initial value:
{
this, "CustomEventTypes", {}, &CommonAuditor::deprecated_property, "[[deprecated]] use EventTypes instead" }

Definition at line 78 of file CommonAuditor.h.

◆ m_types

Gaudi::Property<std::vector<std::string> > CommonAuditor::m_types
private
Initial value:
{
this, "EventTypes", {}, "list of event types to audit ([]=all, ['none']=none)" }

Definition at line 76 of file CommonAuditor.h.


The documentation for this class was generated from the following files:
IOTest.evt
evt
Definition: IOTest.py:107
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::move
T move(T... args)
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
Auditor::m_name
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:126
std::vector< std::string >
CommonAuditor::m_customTypes
Gaudi::Property< std::vector< std::string > > m_customTypes
Definition: CommonAuditor.h:78
std::find
T find(T... args)
GaudiException
Definition: GaudiException.h:31
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:128
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
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
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:203
toStr
const char * toStr(IAuditor::StandardEventType e)
Simple mapping function from IAuditor::StandardEventType to string.
Definition: IAuditor.h:95
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