The Gaudi Framework  master (d98a2936)
Gaudi::Auditor Class Reference

Base class from which all concrete auditor classes should be derived. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Auditor.h>

Inheritance diagram for Gaudi::Auditor:
Collaboration diagram for Gaudi::Auditor:

Public Types

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
 

Public Member Functions

 Auditor (std::string name, ISvcLocator *svcloc)
 
 Auditor (const Auditor &a)=delete
 
Auditoroperator= (const Auditor &rhs)=delete
 
StatusCode sysInitialize () override
 
StatusCode sysFinalize () override
 
void before (std::string const &, std::string const &, EventContext const &) override
 
void after (std::string const &, std::string const &, EventContext const &, StatusCode const &=StatusCode::SUCCESS) override
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
const std::string & name () const override
 
bool isEnabled () const override
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
template<class T = IService>
SmartIF< T > service (std::string_view name, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
- 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, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
 requires (!Gaudi::Details::is_gaudi_property_v< TYPE >) Gaudi
 Helper to wrap a regular data member and use it as a regular property. 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 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...
 

Private Attributes

std::string m_name
 
SmartIF< ISvcLocatorm_pSvcLocator
 Auditor's name for identification. More...
 
Gaudi::Property< int > m_outputLevel
 Pointer to service locator service. More...
 
Gaudi::Property< bool > m_isEnabled { this, "Enable", true, "should the auditor be used or not" }
 
bool m_isInitialized = false
 
bool m_isFinalized = false
 Auditor has been initialized flag. More...
 

Additional Inherited Members

- 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 from which all concrete auditor classes should be derived.

The only base class functionality which may be used in the constructor of a concrete auditor is the declaration of member variables as properties. All other functionality, i.e. the use of services, may be used only in initialize() and afterwards.

Definition at line 33 of file Auditor.h.

Member Typedef Documentation

◆ Factory

using Gaudi::Auditor::Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>

Definition at line 35 of file Auditor.h.

Constructor & Destructor Documentation

◆ Auditor() [1/2]

Gaudi::Auditor::Auditor ( std::string  name,
ISvcLocator svcloc 
)
inline

Definition at line 37 of file Auditor.h.

37 : m_name( std::move( name ) ), m_pSvcLocator( svcloc ){};

◆ Auditor() [2/2]

Gaudi::Auditor::Auditor ( const Auditor a)
delete

Member Function Documentation

◆ after()

void Gaudi::Auditor::after ( std::string const &  ,
std::string const &  ,
EventContext const &  ,
StatusCode const &  = StatusCode::SUCCESS 
)
inlineoverride

Definition at line 45 of file Auditor.h.

46  {}

◆ before()

void Gaudi::Auditor::before ( std::string const &  ,
std::string const &  ,
EventContext const &   
)
inlineoverride

Definition at line 44 of file Auditor.h.

44 {}

◆ finalize()

virtual StatusCode Gaudi::Auditor::finalize ( )
inlinevirtual

Reimplemented in AlgTimingAuditor, and AlgContextAuditor.

Definition at line 49 of file Auditor.h.

49 { return StatusCode::SUCCESS; }

◆ initialize()

virtual StatusCode Gaudi::Auditor::initialize ( )
inlinevirtual

Reimplemented in AlgContextAuditor, MemStatAuditor, AlgTimingAuditor, and ChronoAuditor.

Definition at line 48 of file Auditor.h.

48 { return StatusCode::SUCCESS; }

◆ isEnabled()

bool Gaudi::Auditor::isEnabled ( ) const
inlineoverride

Definition at line 52 of file Auditor.h.

52 { return m_isEnabled; }

◆ name()

const std::string& Gaudi::Auditor::name ( ) const
inlineoverride

Definition at line 51 of file Auditor.h.

51 { return m_name; }

◆ operator=()

Auditor& Gaudi::Auditor::operator= ( const Auditor rhs)
delete

◆ service()

template<class T = IService>
SmartIF<T> Gaudi::Auditor::service ( std::string_view  name,
bool  createIf = false 
) const
inline

Access a service by name, creating it if it doesn't already exist.

Definition at line 63 of file Auditor.h.

63  {
64  return serviceLocator()->service<T>( name, createIf );
65  }

◆ serviceLocator()

SmartIF<ISvcLocator>& Gaudi::Auditor::serviceLocator ( ) const
inlineoverride

The standard service locator.

Returns a pointer to the service locator service. This service may be used by an auditor to request any services it requires in addition to those provided by default.

Definition at line 59 of file Auditor.h.

59 { return m_pSvcLocator; }

◆ sysFinalize()

StatusCode Gaudi::Auditor::sysFinalize ( )
override

catch GaudiExeption

(1) perform the printout of message

(2) print the exception itself (NB! - GaudiException is a linked list of all "previous exceptions")

catch std::exception

(1) perform the printout of message

(2) print the exception itself

catch unknown exception

(1) perform the printout

Definition at line 53 of file Auditor.cpp.

53  {
54  try {
55  // Invoke the finalize() method of the derived class if
56  // it has been initialized.
57  if ( m_isInitialized && !m_isFinalized ) {
58  m_isFinalized = true;
59  return finalize();
60  }
61  return StatusCode::SUCCESS;
62  } catch ( const GaudiException& Exception ) {
63  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
65  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
68  MsgStream logEx( msgSvc(), Exception.tag() );
69  logEx << MSG::ERROR << Exception << endmsg;
70  } catch ( const std::exception& Exception ) {
71  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
73  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
75  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
76  logEx << MSG::ERROR << Exception.what() << endmsg;
77  } catch ( ... ) {
78  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
80  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
81  }
82  return StatusCode::FAILURE;
83 }

◆ sysInitialize()

StatusCode Gaudi::Auditor::sysInitialize ( )
override

catch Gaudi Exception

(1) perform the printout of message

(2) print the exception itself (NB! - GaudiException is a linked list of all "previous exceptions")

catch std::exception

(1) perform the printout of message

(2) print the exception itself (NB! - GaudiException is a linked list of all "previous exceptions")

(1) perform the printout

Definition at line 16 of file Auditor.cpp.

16  {
17  // Bypass the initialization if the auditor is disabled or
18  // has already been initialized.
19  if ( isEnabled() && !m_isInitialized ) {
20  // Setup the default service ... this should be upgraded so as to be configurable.
21  if ( !m_pSvcLocator ) return StatusCode::FAILURE;
22  // this initializes the messaging, in case property update handlers need to print
23  // and update the property value bypassing the update handler
25  // Set the Algorithm's properties
26  bindPropertiesTo( serviceLocator()->getOptsSvc() );
27  try {
28  // Invoke the initialize() method of the derived class
29  return initialize().andThen( [&] { m_isInitialized = true; } );
30  } catch ( const GaudiException& Exception ) {
31  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
33  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
35  MsgStream logEx( msgSvc(), Exception.tag() );
36  logEx << MSG::ERROR << Exception << endmsg;
37  } catch ( const std::exception& Exception ) {
38  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
40  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
42  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
43  logEx << MSG::ERROR << Exception.what() << endmsg;
44  } catch ( ... ) {
46  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
47  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
48  }
49  }
50  return StatusCode::FAILURE;
51 }

Member Data Documentation

◆ m_isEnabled

Gaudi::Property<bool> Gaudi::Auditor::m_isEnabled { this, "Enable", true, "should the auditor be used or not" }
private

Definition at line 76 of file Auditor.h.

◆ m_isFinalized

bool Gaudi::Auditor::m_isFinalized = false
private

Auditor has been initialized flag.

Definition at line 79 of file Auditor.h.

◆ m_isInitialized

bool Gaudi::Auditor::m_isInitialized = false
private

Definition at line 78 of file Auditor.h.

◆ m_name

std::string Gaudi::Auditor::m_name
private

Definition at line 68 of file Auditor.h.

◆ m_outputLevel

Gaudi::Property<int> Gaudi::Auditor::m_outputLevel
private
Initial value:
{
this, "OutputLevel", MSG::NIL,
"output level" }

Pointer to service locator service.

Definition at line 72 of file Auditor.h.

◆ m_pSvcLocator

SmartIF<ISvcLocator> Gaudi::Auditor::m_pSvcLocator
mutableprivate

Auditor's name for identification.

Definition at line 70 of file Auditor.h.


The documentation for this class was generated from the following files:
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:34
Gaudi.Configuration.log
log
Definition: Configuration.py:28
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:163
Gaudi::Auditor::m_isEnabled
Gaudi::Property< bool > m_isEnabled
Definition: Auditor.h:76
Gaudi::Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Auditor's name for identification.
Definition: Auditor.h:70
GaudiException
Definition: GaudiException.h:29
Gaudi::Auditor::m_outputLevel
Gaudi::Property< int > m_outputLevel
Pointer to service locator service.
Definition: Auditor.h:72
PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >::bindPropertiesTo
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Definition: PropertyHolder.h:238
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
Gaudi::Auditor::m_isInitialized
bool m_isInitialized
Definition: Auditor.h:78
Gaudi::Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.h:59
CommonMessaging< implements< IAuditor, IProperty > >::setUpMessaging
MSG::Level setUpMessaging() const
Set up local caches.
Definition: CommonMessaging.h:173
Gaudi::Auditor::name
const std::string & name() const override
Definition: Auditor.h:51
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:229
Gaudi::Auditor::finalize
virtual StatusCode finalize()
Definition: Auditor.h:49
CommonMessaging< implements< IAuditor, IProperty > >::updateMsgStreamOutputLevel
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Definition: CommonMessaging.h:184
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:198
MsgStream
Definition: MsgStream.h:29
MSG::FATAL
@ FATAL
Definition: IMessageSvc.h:22
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
Gaudi::Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.h:48
MSG::NIL
@ NIL
Definition: IMessageSvc.h:22
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:22
Gaudi::Auditor::isEnabled
bool isEnabled() const override
Definition: Auditor.h:52
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
Gaudi::Details::Property::ParsingErrorPolicy::Exception
@ Exception
Gaudi::Auditor::m_name
std::string m_name
Definition: Auditor.h:68
Gaudi::Auditor::m_isFinalized
bool m_isFinalized
Auditor has been initialized flag.
Definition: Auditor.h:79