Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (f31105fd)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Auditor Class Reference

#include <GaudiKernel/Auditor.h>

Inheritance diagram for Auditor:
Collaboration diagram for 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)
 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
 
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...
 

Private Attributes

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

Author
David Quarrie
Date
2000
Author
Marco Clemencic
Date
2008-03

Definition at line 42 of file Auditor.h.

Member Typedef Documentation

◆ Factory

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

Definition at line 44 of file Auditor.h.

Constructor & Destructor Documentation

◆ Auditor() [1/2]

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

Constructor.

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

Definition at line 21 of file Auditor.cpp.

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

◆ Auditor() [2/2]

Auditor::Auditor ( const Auditor a)
delete

Member Function Documentation

◆ after() [1/4]

void Auditor::after ( CustomEventTypeRef  ,
const std::string ,
const StatusCode  
)
inlineoverride

Definition at line 75 of file Auditor.h.

75 {}

◆ after() [2/4]

void Auditor::after ( CustomEventTypeRef  ,
INamedInterface ,
const StatusCode  
)
inlineoverride

Definition at line 74 of file Auditor.h.

74 {}

◆ after() [3/4]

void Auditor::after ( StandardEventType  ,
const std::string ,
const StatusCode  
)
inlineoverride

Definition at line 72 of file Auditor.h.

72 {}

◆ after() [4/4]

void Auditor::after ( StandardEventType  ,
INamedInterface ,
const StatusCode  
)
inlineoverride

Definition at line 71 of file Auditor.h.

71 {}

◆ before() [1/4]

void Auditor::before ( CustomEventTypeRef  ,
const std::string  
)
inlineoverride

Definition at line 69 of file Auditor.h.

69 {}

◆ before() [2/4]

void Auditor::before ( CustomEventTypeRef  ,
INamedInterface  
)
inlineoverride

Definition at line 68 of file Auditor.h.

68 {}

◆ before() [3/4]

void Auditor::before ( StandardEventType  ,
const std::string  
)
inlineoverride

Definition at line 66 of file Auditor.h.

66 {}

◆ before() [4/4]

void Auditor::before ( StandardEventType  ,
INamedInterface  
)
inlineoverride

The following methods are meant to be implemented by the child class...

Definition at line 65 of file Auditor.h.

65 {}

◆ finalize()

virtual StatusCode Auditor::finalize ( )
inlinevirtual

Reimplemented in PerfMonAuditor, AlgTimingAuditor, Google::AuditorBase, and AlgContextAuditor.

Definition at line 78 of file Auditor.h.

78 { return StatusCode::SUCCESS; }

◆ initialize()

virtual StatusCode Auditor::initialize ( )
inlinevirtual

◆ isEnabled()

bool Auditor::isEnabled ( ) const
inlineoverride

Definition at line 82 of file Auditor.h.

82 { return m_isEnabled; }

◆ name()

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

Definition at line 80 of file Auditor.h.

80 { return m_name; }

◆ operator=()

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

◆ service() [1/2]

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

Definition at line 106 of file Auditor.h.

106  {
107  return serviceLocator()->service<T>( name, createIf );
108  }

◆ service() [2/2]

template<class T >
StatusCode Auditor::service ( std::string_view  name,
T *&  svc,
bool  createIf = false 
) const
inline

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

Definition at line 93 of file Auditor.h.

94  {
95  auto ptr = serviceLocator()->service<T>( name, createIf );
96  if ( ptr ) {
97  svc = ptr.get();
98  svc->addRef();
99  return StatusCode::SUCCESS;
100  }
101  svc = nullptr;
102  return StatusCode::FAILURE;
103  }

◆ serviceLocator()

SmartIF<ISvcLocator>& 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 88 of file Auditor.h.

88 { return m_pSvcLocator; }

◆ sysFinalize()

StatusCode Auditor::sysFinalize ( )
override

Finalization method invoked by the framework.

This method is responsible for any bookkeeping of initialization required by the framework itself.

RETURN !!!

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 79 of file Auditor.cpp.

79  {
81  try {
82  //
83  // Invoke the finalize() method of the derived class if
84  // it has been initialized.
85  if ( m_isInitialized && !m_isFinalized ) {
86  m_isFinalized = true;
87  sc = finalize();
88  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
89  }
90  return sc;
91  //
92  } catch ( const GaudiException& Exception )
93  {
95  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
96  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
99  MsgStream logEx( msgSvc(), Exception.tag() );
100  logEx << MSG::ERROR << Exception << endmsg;
101  } catch ( const std::exception& Exception )
102  {
104  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
105  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
107  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
108  logEx << MSG::ERROR << Exception.what() << endmsg;
109  } catch ( ... )
110  {
112  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
113  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
114  }
116  return StatusCode::FAILURE;
117 }

◆ sysInitialize()

StatusCode Auditor::sysInitialize ( )
override

Initialization method invoked by the framework.

This method is responsible for any bookkeeping of initialization required by the framework itself.

RETURN !!!

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 25 of file Auditor.cpp.

25  {
26  StatusCode sc;
27 
28  // Bypass the initialization if the auditor is disabled or
29  // has already been initialized.
30  if ( isEnabled() && !m_isInitialized ) {
31 
32  // Setup the default service ... this should be upgraded so as to be configurable.
33  if ( !m_pSvcLocator ) return StatusCode::FAILURE;
34 
35  // this initializes the messaging, in case property update handlers need to print
36  // and update the property value bypassing the update handler
38 
39  // Set the Algorithm's properties
40  bindPropertiesTo( serviceLocator()->getOptsSvc() );
41 
42  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
43 
44  {
45  try {
46  // Invoke the initialize() method of the derived class
47  sc = initialize();
48  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
49  m_isInitialized = true;
50 
51  return sc;
52  } catch ( const GaudiException& Exception )
53  {
55  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
56  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
58  MsgStream logEx( msgSvc(), Exception.tag() );
59  logEx << MSG::ERROR << Exception << endmsg;
60  } catch ( const std::exception& Exception )
61  {
63  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
64  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
66  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
67  logEx << MSG::ERROR << Exception.what() << endmsg;
68  } catch ( ... ) {
70  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
71  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
72  }
73  }
74  }
76  return StatusCode::FAILURE;
77 }

Member Data Documentation

◆ m_isEnabled

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

Definition at line 119 of file Auditor.h.

◆ m_isFinalized

bool Auditor::m_isFinalized = false
private

Auditor has been finalized flag.

Definition at line 122 of file Auditor.h.

◆ m_isInitialized

bool Auditor::m_isInitialized = false
private

Auditor has been initialized flag.

Definition at line 121 of file Auditor.h.

◆ m_name

std::string Auditor::m_name
private

Auditor's name for identification.

Definition at line 111 of file Auditor.h.

◆ m_outputLevel

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

Definition at line 115 of file Auditor.h.

◆ m_pSvcLocator

SmartIF<ISvcLocator> Auditor::m_pSvcLocator
mutableprivate

Pointer to service locator service.

Definition at line 113 of file Auditor.h.


The documentation for this class was generated from the following files:
Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.h:88
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.h:77
std::exception
STL class.
Gaudi.Configuration.log
log
Definition: Configuration.py:28
std::move
T move(T... args)
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:315
Auditor::m_name
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:111
Auditor::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Auditor.h:115
GaudiException
Definition: GaudiException.h:32
Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:113
PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >::bindPropertiesTo
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Definition: PropertyHolder.h:252
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
CommonMessaging< implements< IAuditor, IProperty > >::setUpMessaging
MSG::Level setUpMessaging() const
Set up local caches.
Definition: CommonMessaging.h:174
Auditor::m_isFinalized
bool m_isFinalized
Auditor has been finalized flag.
Definition: Auditor.h:122
StatusCode
Definition: StatusCode.h:65
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:234
Auditor::finalize
virtual StatusCode finalize()
Definition: Auditor.h:78
CommonMessaging< implements< IAuditor, IProperty > >::updateMsgStreamOutputLevel
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Definition: CommonMessaging.h:185
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
MsgStream
Definition: MsgStream.h:33
MSG::FATAL
@ FATAL
Definition: IMessageSvc.h:25
Auditor::isEnabled
bool isEnabled() const override
Definition: Auditor.h:82
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
Auditor::m_isEnabled
Gaudi::Property< bool > m_isEnabled
Definition: Auditor.h:119
MSG::NIL
@ NIL
Definition: IMessageSvc.h:25
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
Auditor::m_isInitialized
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:121
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Auditor::name
const std::string & name() const override
Definition: Auditor.h:80
Gaudi::Details::Property::ParsingErrorPolicy::Exception
@ Exception