The Gaudi Framework  master (37c0b60a)
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
 
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...
 

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 43 of file Auditor.h.

Member Typedef Documentation

◆ Factory

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

Definition at line 45 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  
)
override

Definition at line 139 of file Auditor.cpp.

139 {}

◆ after() [2/4]

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

Definition at line 138 of file Auditor.cpp.

138 {}

◆ after() [3/4]

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

Definition at line 136 of file Auditor.cpp.

136 {}

◆ after() [4/4]

void Auditor::after ( StandardEventType  evt,
INamedInterface obj,
const StatusCode sc 
)
override

Definition at line 112 of file Auditor.cpp.

112  {
113  switch ( evt ) {
114  case Initialize:
115  afterInitialize( obj );
116  break;
117  case ReInitialize:
118  afterReinitialize( obj );
119  break;
120  case Execute:
121  afterExecute( obj, sc );
122  break;
123  case Finalize:
124  afterFinalize( obj );
125  break;
126  case Start:
127  break;
128  case Stop:
129  break;
130  case ReStart:
131  break;
132  default:
133  break; // do nothing
134  }
135 }

◆ afterExecute()

void Auditor::afterExecute ( INamedInterface ,
const StatusCode  
)
override

Definition at line 146 of file Auditor.cpp.

146 {}

◆ afterFinalize()

void Auditor::afterFinalize ( INamedInterface )
override

Definition at line 148 of file Auditor.cpp.

148 {}

◆ afterInitialize()

void Auditor::afterInitialize ( INamedInterface )
override

Definition at line 142 of file Auditor.cpp.

142 {}

◆ afterReinitialize()

void Auditor::afterReinitialize ( INamedInterface )
override

Definition at line 144 of file Auditor.cpp.

144 {}

◆ before() [1/4]

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

Definition at line 109 of file Auditor.cpp.

109 {}

◆ before() [2/4]

void Auditor::before ( CustomEventTypeRef  ,
INamedInterface  
)
override

Definition at line 108 of file Auditor.cpp.

108 {}

◆ before() [3/4]

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

Definition at line 106 of file Auditor.cpp.

106 {}

◆ before() [4/4]

void Auditor::before ( StandardEventType  evt,
INamedInterface obj 
)
override

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

Definition at line 82 of file Auditor.cpp.

82  {
83  switch ( evt ) {
84  case Initialize:
85  beforeInitialize( obj );
86  break;
87  case ReInitialize:
88  beforeReinitialize( obj );
89  break;
90  case Execute:
91  beforeExecute( obj );
92  break;
93  case Finalize:
94  beforeFinalize( obj );
95  break;
96  case Start:
97  break;
98  case Stop:
99  break;
100  case ReStart:
101  break;
102  default:
103  break; // do nothing
104  }
105 }

◆ beforeExecute()

void Auditor::beforeExecute ( INamedInterface )
override

Definition at line 145 of file Auditor.cpp.

145 {}

◆ beforeFinalize()

void Auditor::beforeFinalize ( INamedInterface )
override

Definition at line 147 of file Auditor.cpp.

147 {}

◆ beforeInitialize()

void Auditor::beforeInitialize ( INamedInterface )
override

Definition at line 141 of file Auditor.cpp.

141 {}

◆ beforeReinitialize()

void Auditor::beforeReinitialize ( INamedInterface )
override

Definition at line 143 of file Auditor.cpp.

143 {}

◆ finalize()

StatusCode Auditor::finalize ( )
virtual

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

Definition at line 190 of file Auditor.cpp.

190 { return StatusCode::SUCCESS; }

◆ initialize()

StatusCode Auditor::initialize ( )
virtual

◆ isEnabled()

bool Auditor::isEnabled ( ) const
override

Definition at line 194 of file Auditor.cpp.

194 { return m_isEnabled; }

◆ name()

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

Definition at line 192 of file Auditor.cpp.

192 { 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 121 of file Auditor.h.

121  {
122  return serviceLocator()->service<T>( name, createIf );
123  }

◆ 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 108 of file Auditor.h.

109  {
110  auto ptr = serviceLocator()->service<T>( name, createIf );
111  if ( ptr ) {
112  svc = ptr.get();
113  svc->addRef();
114  return StatusCode::SUCCESS;
115  }
116  svc = nullptr;
117  return StatusCode::FAILURE;
118  }

◆ serviceLocator()

SmartIF< ISvcLocator > & Auditor::serviceLocator ( ) const
override

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

196 { 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 150 of file Auditor.cpp.

150  {
152  try {
153  //
154  // Invoke the finalize() method of the derived class if
155  // it has been initialized.
156  if ( m_isInitialized && !m_isFinalized ) {
157  m_isFinalized = true;
158  sc = finalize();
159  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
160  }
161  return sc;
162  //
163  } catch ( const GaudiException& Exception )
164  {
166  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
167  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
170  MsgStream logEx( msgSvc(), Exception.tag() );
171  logEx << MSG::ERROR << Exception << endmsg;
172  } catch ( const std::exception& Exception )
173  {
175  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
176  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
178  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
179  logEx << MSG::ERROR << Exception.what() << endmsg;
180  } catch ( ... )
181  {
183  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
184  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
185  }
187  return StatusCode::FAILURE;
188 }

◆ 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 134 of file Auditor.h.

◆ m_isFinalized

bool Auditor::m_isFinalized = false
private

Auditor has been finalized flag.

Definition at line 137 of file Auditor.h.

◆ m_isInitialized

bool Auditor::m_isInitialized = false
private

Auditor has been initialized flag.

Definition at line 136 of file Auditor.h.

◆ m_name

std::string Auditor::m_name
private

Auditor's name for identification.

Definition at line 126 of file Auditor.h.

◆ m_outputLevel

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

Definition at line 130 of file Auditor.h.

◆ m_pSvcLocator

SmartIF<ISvcLocator> Auditor::m_pSvcLocator
mutableprivate

Pointer to service locator service.

Definition at line 128 of file Auditor.h.


The documentation for this class was generated from the following files:
IOTest.evt
evt
Definition: IOTest.py:107
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
Auditor::beforeInitialize
void beforeInitialize(INamedInterface *) override
Definition: Auditor.cpp:141
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:314
Auditor::m_name
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:126
Auditor::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Auditor.h:130
GaudiException
Definition: GaudiException.h:31
Auditor::beforeReinitialize
void beforeReinitialize(INamedInterface *) override
Definition: Auditor.cpp:143
Auditor::afterExecute
void afterExecute(INamedInterface *, const StatusCode &) override
Definition: Auditor.cpp:146
Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:128
PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >::bindPropertiesTo
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Definition: PropertyHolder.h:252
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
Auditor::finalize
virtual StatusCode finalize()
Definition: Auditor.cpp:190
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.cpp:79
Auditor::name
const std::string & name() const override
Definition: Auditor.cpp:192
Auditor::beforeFinalize
void beforeFinalize(INamedInterface *) override
Definition: Auditor.cpp:147
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:137
StatusCode
Definition: StatusCode.h:65
Auditor::afterReinitialize
void afterReinitialize(INamedInterface *) override
Definition: Auditor.cpp:144
Auditor::afterFinalize
void afterFinalize(INamedInterface *) override
Definition: Auditor.cpp:148
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:237
CommonMessaging< implements< IAuditor, IProperty > >::updateMsgStreamOutputLevel
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Definition: CommonMessaging.h:185
Auditor::afterInitialize
void afterInitialize(INamedInterface *) override
Definition: Auditor.cpp:142
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::beforeExecute
void beforeExecute(INamedInterface *) override
Definition: Auditor.cpp:145
Auditor::isEnabled
bool isEnabled() const override
Definition: Auditor.cpp:194
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:134
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:136
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Gaudi::Details::Property::ParsingErrorPolicy::Exception
@ Exception
Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.cpp:196