The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using base_class
 

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.
 
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.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
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.
 
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.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
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)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Private Attributes

std::string m_name
 
SmartIF< ISvcLocatorm_pSvcLocator
 Auditor's name for identification.
 
Gaudi::Property< int > m_outputLevel
 Pointer to service locator service.
 
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.
 

Additional Inherited Members

- Protected Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 

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 ){};
SmartIF< ISvcLocator > m_pSvcLocator
Auditor's name for identification.
Definition Auditor.h:70
const std::string & name() const override
Definition Auditor.h:51
std::string m_name
Definition Auditor.h:68

◆ 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 AlgContextAuditor, and AlgTimingAuditor.

Definition at line 49 of file Auditor.h.

49{ return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ initialize()

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

Reimplemented in AlgContextAuditor, AlgTimingAuditor, ChronoAuditor, and MemStatAuditor.

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; }
Gaudi::Property< bool > m_isEnabled
Definition Auditor.h:76

◆ 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 }
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition Auditor.h:59
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.

◆ 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.
58 m_isFinalized = true;
59 return finalize();
60 }
62 } catch ( const GaudiException& Exception ) {
64 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 ) {
72 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 ( ... ) {
79 MsgStream log( msgSvc(), name() + ".sysFinalize()" );
80 log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
81 }
83}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool m_isFinalized
Auditor has been initialized flag.
Definition Auditor.h:79
bool m_isInitialized
Definition Auditor.h:78
virtual StatusCode finalize()
Definition Auditor.h:49
constexpr static const auto FAILURE
Definition StatusCode.h:100
@ FATAL
Definition IMessageSvc.h:22
@ ERROR
Definition IMessageSvc.h:22

◆ 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.
22 // this initializes the messaging, in case property update handlers need to print
23 // and update the property value bypassing the update handler
24 m_outputLevel.value() = setUpMessaging();
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 ) {
32 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 ) {
39 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 }
51}
Gaudi::Property< int > m_outputLevel
Pointer to service locator service.
Definition Auditor.h:72
virtual StatusCode initialize()
Definition Auditor.h:48
bool isEnabled() const override
Definition Auditor.h:52
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition StatusCode.h:163

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.

76{ this, "Enable", true, "should the auditor be used or not" };

◆ 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" }
Gaudi::Property< int > m_outputLevel
Definition AlgTool.h:278
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
@ NIL
Definition IMessageSvc.h:22

Pointer to service locator service.

Definition at line 72 of file Auditor.h.

72 {
73 this, "OutputLevel", MSG::NIL,
74 [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); },
75 "output level" };

◆ 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: