The Gaudi Framework  v29r0 (ff2e7097)
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

typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
- 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
 
 ~PropertyHolder () override=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, TYPE &value, const std::string &doc="none") const
 
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
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
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...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. 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 {this, "OutputLevel", MSG::NIL, "output level"}
 
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 > >
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 35 of file Auditor.h.

Member Typedef Documentation

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.

13  : m_name( name ), m_pSvcLocator( pSvcLocator ), m_isInitialized( false ), m_isFinalized( false )
14 {
15  m_outputLevel.declareUpdateHandler(
17 }
std::string m_name
Auditor&#39;s name for identification.
Definition: Auditor.h:135
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:142
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:137
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
Gaudi::Property< int > m_outputLevel
Definition: Auditor.h:139
bool m_isFinalized
Auditor has been finalized flag.
Definition: Auditor.h:143
Auditor::Auditor ( const Auditor a)
delete

Member Function Documentation

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

Definition at line 110 of file Auditor.cpp.

111 {
112  switch ( evt ) {
113  case Initialize:
114  afterInitialize( obj );
115  break;
116  case ReInitialize:
117  afterReinitialize( obj );
118  break;
119  case Execute:
120  afterExecute( obj, sc );
121  break;
122  case BeginRun:
123  afterBeginRun( obj );
124  break;
125  case EndRun:
126  afterEndRun( obj );
127  break;
128  case Finalize:
129  afterFinalize( obj );
130  break;
131  case Start:
132  break;
133  case Stop:
134  break;
135  case ReStart:
136  break;
137  default:
138  break; // do nothing
139  }
140 }
void afterEndRun(INamedInterface *) override
Definition: Auditor.cpp:155
void afterBeginRun(INamedInterface *) override
Definition: Auditor.cpp:153
void afterExecute(INamedInterface *, const StatusCode &) override
Definition: Auditor.cpp:151
void afterInitialize(INamedInterface *) override
Definition: Auditor.cpp:147
void afterFinalize(INamedInterface *) override
Definition: Auditor.cpp:157
evt
Definition: IOTest.py:96
void afterReinitialize(INamedInterface *) override
Definition: Auditor.cpp:149
void Auditor::after ( StandardEventType  ,
const std::string ,
const StatusCode  
)
override

Definition at line 141 of file Auditor.cpp.

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

Definition at line 143 of file Auditor.cpp.

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

Definition at line 144 of file Auditor.cpp.

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

Definition at line 153 of file Auditor.cpp.

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

Definition at line 155 of file Auditor.cpp.

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

Definition at line 151 of file Auditor.cpp.

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

Definition at line 157 of file Auditor.cpp.

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

Definition at line 147 of file Auditor.cpp.

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

Definition at line 149 of file Auditor.cpp.

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

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

Definition at line 73 of file Auditor.cpp.

74 {
75  switch ( evt ) {
76  case Initialize:
77  beforeInitialize( obj );
78  break;
79  case ReInitialize:
80  beforeReinitialize( obj );
81  break;
82  case Execute:
83  beforeExecute( obj );
84  break;
85  case BeginRun:
86  beforeBeginRun( obj );
87  break;
88  case EndRun:
89  beforeEndRun( obj );
90  break;
91  case Finalize:
92  beforeFinalize( obj );
93  break;
94  case Start:
95  break;
96  case Stop:
97  break;
98  case ReStart:
99  break;
100  default:
101  break; // do nothing
102  }
103 }
void beforeInitialize(INamedInterface *) override
Definition: Auditor.cpp:146
void beforeBeginRun(INamedInterface *) override
Definition: Auditor.cpp:152
void beforeExecute(INamedInterface *) override
Definition: Auditor.cpp:150
void beforeReinitialize(INamedInterface *) override
Definition: Auditor.cpp:148
void beforeFinalize(INamedInterface *) override
Definition: Auditor.cpp:156
void beforeEndRun(INamedInterface *) override
Definition: Auditor.cpp:154
evt
Definition: IOTest.py:96
void Auditor::before ( StandardEventType  ,
const std::string  
)
override

Definition at line 104 of file Auditor.cpp.

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

Definition at line 106 of file Auditor.cpp.

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

Definition at line 107 of file Auditor.cpp.

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

Definition at line 152 of file Auditor.cpp.

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

Definition at line 154 of file Auditor.cpp.

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

Definition at line 150 of file Auditor.cpp.

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

Definition at line 156 of file Auditor.cpp.

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

Definition at line 146 of file Auditor.cpp.

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

Definition at line 148 of file Auditor.cpp.

148 {}
StatusCode Auditor::finalize ( )
virtual
bool Auditor::isEnabled ( ) const
override

Definition at line 204 of file Auditor.cpp.

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

Definition at line 202 of file Auditor.cpp.

202 { return m_name; }
std::string m_name
Auditor&#39;s name for identification.
Definition: Auditor.h:135
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 109 of file Auditor.h.

110  {
111  auto ptr = serviceLocator()->service<T>( name, createIf );
112  if ( ptr ) {
113  svc = ptr.get();
114  svc->addRef();
115  return StatusCode::SUCCESS;
116  }
117  svc = nullptr;
118  return StatusCode::FAILURE;
119  }
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.cpp:206
const std::string & name() const override
Definition: Auditor.cpp:202
template<class T = IService>
SmartIF<T> Auditor::service ( const std::string name,
bool  createIf = false 
) const
inline

Definition at line 122 of file Auditor.h.

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

206 { return m_pSvcLocator; }
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:137
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 209 of file Auditor.cpp.

210 {
211  if ( !m_pSvcLocator ) return StatusCode::FAILURE;
212  auto jos = service<IJobOptionsSvc>( "JobOptionsSvc" );
213  if ( !jos ) return StatusCode::FAILURE;
214  jos->setMyProperties( name(), this ).ignore();
216  return StatusCode::SUCCESS;
217 }
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:137
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Gaudi::Property< int > m_outputLevel
Definition: Auditor.h:139
const std::string & name() const override
Definition: Auditor.cpp:202
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 159 of file Auditor.cpp.

160 {
162  try {
163  //
164  // Invoke the finalize() method of the derived class if
165  // it has been initialized.
166  if ( m_isInitialized && !m_isFinalized ) {
167  m_isFinalized = true;
168  sc = finalize();
169  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
170  }
171  return sc;
172  //
173  } catch ( const GaudiException& Exception )
174  {
176  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
177  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
180  MsgStream logEx( msgSvc(), Exception.tag() );
181  logEx << MSG::ERROR << Exception << endmsg;
182  } catch ( const std::exception& Exception )
183  {
185  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
186  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
188  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
189  logEx << MSG::ERROR << Exception.what() << endmsg;
190  } catch ( ... )
191  {
193  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
194  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
195  }
197  return StatusCode::FAILURE;
198 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual StatusCode finalize()
Definition: Auditor.cpp:200
Define general base for Gaudi exception.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:142
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
const std::string & name() const override
Definition: Auditor.cpp:202
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
bool m_isFinalized
Auditor has been finalized flag.
Definition: Auditor.h:143
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 20 of file Auditor.cpp.

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

Member Data Documentation

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

Definition at line 140 of file Auditor.h.

bool Auditor::m_isFinalized = false
private

Auditor has been finalized flag.

Definition at line 143 of file Auditor.h.

bool Auditor::m_isInitialized = false
private

Auditor has been initialized flag.

Definition at line 142 of file Auditor.h.

std::string Auditor::m_name
private

Auditor's name for identification.

Definition at line 135 of file Auditor.h.

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

Definition at line 139 of file Auditor.h.

SmartIF<ISvcLocator> Auditor::m_pSvcLocator
mutableprivate

Pointer to service locator service.

Definition at line 137 of file Auditor.h.


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