The Gaudi Framework  v31r0 (aeb156f0)
Auditor Class Reference

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

#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 (const 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
 
void beforeBeginRun (INamedInterface *) override
 
void afterBeginRun (INamedInterface *) override
 
void beforeEndRun (INamedInterface *) override
 
void afterEndRun (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 (const std::string &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 (const std::string &name, bool createIf=false) const
 
StatusCode setProperties ()
 Set the auditor's properties. 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, 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 Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &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 (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 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...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) 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 PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- 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 34 of file Auditor.h.

Member Typedef Documentation

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

Definition at line 36 of file Auditor.h.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 12 of file Auditor.cpp.

12 : m_name( name ), m_pSvcLocator( pSvcLocator ) {}
std::string m_name
Auditor&#39;s name for identification.
Definition: Auditor.h:129
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:131
Auditor::Auditor ( const Auditor a)
delete

Member Function Documentation

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

Definition at line 103 of file Auditor.cpp.

103  {
104  switch ( evt ) {
105  case Initialize:
106  afterInitialize( obj );
107  break;
108  case ReInitialize:
109  afterReinitialize( obj );
110  break;
111  case Execute:
112  afterExecute( obj, sc );
113  break;
114  case BeginRun:
115  afterBeginRun( obj );
116  break;
117  case EndRun:
118  afterEndRun( obj );
119  break;
120  case Finalize:
121  afterFinalize( obj );
122  break;
123  case Start:
124  break;
125  case Stop:
126  break;
127  case ReStart:
128  break;
129  default:
130  break; // do nothing
131  }
132 }
void afterEndRun(INamedInterface *) override
Definition: Auditor.cpp:147
void afterBeginRun(INamedInterface *) override
Definition: Auditor.cpp:145
void afterExecute(INamedInterface *, const StatusCode &) override
Definition: Auditor.cpp:143
void afterInitialize(INamedInterface *) override
Definition: Auditor.cpp:139
void afterFinalize(INamedInterface *) override
Definition: Auditor.cpp:149
evt
Definition: IOTest.py:94
void afterReinitialize(INamedInterface *) override
Definition: Auditor.cpp:141
void Auditor::after ( StandardEventType  ,
const std::string ,
const StatusCode  
)
override

Definition at line 133 of file Auditor.cpp.

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

Definition at line 135 of file Auditor.cpp.

135 {}
void Auditor::after ( CustomEventTypeRef  ,
const std::string ,
const StatusCode  
)
override

Definition at line 136 of file Auditor.cpp.

136 {}
void Auditor::afterBeginRun ( INamedInterface )
override

Definition at line 145 of file Auditor.cpp.

145 {}
void Auditor::afterEndRun ( INamedInterface )
override

Definition at line 147 of file Auditor.cpp.

147 {}
void Auditor::afterExecute ( INamedInterface ,
const StatusCode  
)
override

Definition at line 143 of file Auditor.cpp.

143 {}
void Auditor::afterFinalize ( INamedInterface )
override

Definition at line 149 of file Auditor.cpp.

149 {}
void Auditor::afterInitialize ( INamedInterface )
override

Definition at line 139 of file Auditor.cpp.

139 {}
void Auditor::afterReinitialize ( INamedInterface )
override

Definition at line 141 of file Auditor.cpp.

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

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

Definition at line 67 of file Auditor.cpp.

67  {
68  switch ( evt ) {
69  case Initialize:
70  beforeInitialize( obj );
71  break;
72  case ReInitialize:
73  beforeReinitialize( obj );
74  break;
75  case Execute:
76  beforeExecute( obj );
77  break;
78  case BeginRun:
79  beforeBeginRun( obj );
80  break;
81  case EndRun:
82  beforeEndRun( obj );
83  break;
84  case Finalize:
85  beforeFinalize( obj );
86  break;
87  case Start:
88  break;
89  case Stop:
90  break;
91  case ReStart:
92  break;
93  default:
94  break; // do nothing
95  }
96 }
void beforeInitialize(INamedInterface *) override
Definition: Auditor.cpp:138
void beforeBeginRun(INamedInterface *) override
Definition: Auditor.cpp:144
void beforeExecute(INamedInterface *) override
Definition: Auditor.cpp:142
void beforeReinitialize(INamedInterface *) override
Definition: Auditor.cpp:140
void beforeFinalize(INamedInterface *) override
Definition: Auditor.cpp:148
void beforeEndRun(INamedInterface *) override
Definition: Auditor.cpp:146
evt
Definition: IOTest.py:94
void Auditor::before ( StandardEventType  ,
const std::string  
)
override

Definition at line 97 of file Auditor.cpp.

97 {}
void Auditor::before ( CustomEventTypeRef  ,
INamedInterface  
)
override

Definition at line 99 of file Auditor.cpp.

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

Definition at line 100 of file Auditor.cpp.

100 {}
void Auditor::beforeBeginRun ( INamedInterface )
override

Definition at line 144 of file Auditor.cpp.

144 {}
void Auditor::beforeEndRun ( INamedInterface )
override

Definition at line 146 of file Auditor.cpp.

146 {}
void Auditor::beforeExecute ( INamedInterface )
override

Definition at line 142 of file Auditor.cpp.

142 {}
void Auditor::beforeFinalize ( INamedInterface )
override

Definition at line 148 of file Auditor.cpp.

148 {}
void Auditor::beforeInitialize ( INamedInterface )
override

Definition at line 138 of file Auditor.cpp.

138 {}
void Auditor::beforeReinitialize ( INamedInterface )
override

Definition at line 140 of file Auditor.cpp.

140 {}
StatusCode Auditor::finalize ( )
virtual

Reimplemented in PerfMonAuditor, Google::AuditorBase, TimingAuditor, AlgContextAuditor, and AlgErrorAuditor.

Definition at line 191 of file Auditor.cpp.

191 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode Auditor::initialize ( )
virtual
bool Auditor::isEnabled ( ) const
override

Definition at line 195 of file Auditor.cpp.

195 { return m_isEnabled; }
Gaudi::Property< bool > m_isEnabled
Definition: Auditor.h:137
const std::string & Auditor::name ( ) const
override

Definition at line 193 of file Auditor.cpp.

193 { return m_name; }
std::string m_name
Auditor&#39;s name for identification.
Definition: Auditor.h:129
Auditor& Auditor::operator= ( const Auditor rhs)
delete
template<class T >
StatusCode Auditor::service ( const std::string name,
T *&  svc,
bool  createIf = false 
) const
inline

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

Definition at line 105 of file Auditor.h.

105  {
106  auto ptr = serviceLocator()->service<T>( name, createIf );
107  if ( ptr ) {
108  svc = ptr.get();
109  svc->addRef();
110  return StatusCode::SUCCESS;
111  }
112  svc = nullptr;
113  return StatusCode::FAILURE;
114  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.cpp:197
constexpr static const auto FAILURE
Definition: StatusCode.h:86
const std::string & name() const override
Definition: Auditor.cpp:193
template<class T = IService>
SmartIF<T> Auditor::service ( const std::string name,
bool  createIf = false 
) const
inline

Definition at line 117 of file Auditor.h.

117  {
118  return serviceLocator()->service<T>( name, createIf );
119  }
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.cpp:197
const std::string & name() const override
Definition: Auditor.cpp:193
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 197 of file Auditor.cpp.

197 { return m_pSvcLocator; }
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:131
StatusCode Auditor::setProperties ( )

Set the auditor's properties.

This method requests the job options service to set the values of any declared properties. The method is invoked from within sysInitialize() by the framework and does not need to be explicitly called by a concrete auditor.

Definition at line 200 of file Auditor.cpp.

200  {
201  if ( !m_pSvcLocator ) return StatusCode::FAILURE;
202  auto jos = service<IJobOptionsSvc>( "JobOptionsSvc" );
203  if ( !jos ) return StatusCode::FAILURE;
204 
205  // this initializes the messaging, in case property update handlers need to print
206  // and update the property value bypassing the update handler
207  m_outputLevel.value() = setUpMessaging();
208 
209  return jos->setMyProperties( name(), this );
210 }
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:131
MSG::Level setUpMessaging() const
Set up local caches.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Gaudi::Property< int > m_outputLevel
Definition: Auditor.h:133
const std::string & name() const override
Definition: Auditor.cpp:193
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 151 of file Auditor.cpp.

151  {
153  try {
154  //
155  // Invoke the finalize() method of the derived class if
156  // it has been initialized.
157  if ( m_isInitialized && !m_isFinalized ) {
158  m_isFinalized = true;
159  sc = finalize();
160  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
161  }
162  return sc;
163  //
164  } catch ( const GaudiException& Exception )
165  {
167  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
168  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
171  MsgStream logEx( msgSvc(), Exception.tag() );
172  logEx << MSG::ERROR << Exception << endmsg;
173  } catch ( const std::exception& Exception )
174  {
176  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
177  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
179  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
180  logEx << MSG::ERROR << Exception.what() << endmsg;
181  } catch ( ... )
182  {
184  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
185  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
186  }
188  return StatusCode::FAILURE;
189 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual StatusCode finalize()
Definition: Auditor.cpp:191
Define general base for Gaudi exception.
bool isSuccess() const
Definition: StatusCode.h:267
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:139
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual const std::string & tag() const
name tag for the exception, or exception type
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
STL class.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
const std::string & name() const override
Definition: Auditor.cpp:193
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
bool m_isFinalized
Auditor has been finalized flag.
Definition: Auditor.h:140
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 15 of file Auditor.cpp.

15  {
16  StatusCode sc;
17 
18  // Bypass the initialization if the auditor is disabled or
19  // has already been initialized.
20  if ( isEnabled() && !m_isInitialized ) {
21 
22  // Setup the default service ... this should be upgraded so as to be configurable.
23  if ( !m_pSvcLocator ) return StatusCode::FAILURE;
24 
25  // Set the Auditor's properties
26  sc = setProperties();
27  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
28 
29  {
30  try {
31  // Invoke the initialize() method of the derived class
32  sc = initialize();
33  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
34  m_isInitialized = true;
35 
36  return sc;
37  } catch ( const GaudiException& Exception )
38  {
40  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
41  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
43  MsgStream logEx( msgSvc(), Exception.tag() );
44  logEx << MSG::ERROR << Exception << endmsg;
45  } catch ( const std::exception& Exception )
46  {
48  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
49  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
51  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
52  logEx << MSG::ERROR << Exception.what() << endmsg;
53  } catch ( ... ) {
55  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
56  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
57  }
58  }
59  }
61  return StatusCode::FAILURE;
62 }
bool isEnabled() const override
Definition: Auditor.cpp:195
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
bool isSuccess() const
Definition: StatusCode.h:267
StatusCode setProperties()
Set the auditor&#39;s properties.
Definition: Auditor.cpp:200
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:139
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:131
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual const std::string & tag() const
name tag for the exception, or exception type
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
STL class.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
virtual StatusCode initialize()
Definition: Auditor.cpp:64
const std::string & name() const override
Definition: Auditor.cpp:193
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

Member Data Documentation

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

Definition at line 137 of file Auditor.h.

bool Auditor::m_isFinalized = false
private

Auditor has been finalized flag.

Definition at line 140 of file Auditor.h.

bool Auditor::m_isInitialized = false
private

Auditor has been initialized flag.

Definition at line 139 of file Auditor.h.

std::string Auditor::m_name
private

Auditor's name for identification.

Definition at line 129 of file Auditor.h.

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

Definition at line 133 of file Auditor.h.

SmartIF<ISvcLocator> Auditor::m_pSvcLocator
mutableprivate

Pointer to service locator service.

Definition at line 131 of file Auditor.h.


The documentation for this class was generated from the following files: