The Gaudi Framework  v33r0 (d5ea422b)
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
 
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 44 of file Auditor.h.

Member Typedef Documentation

◆ Factory

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

Definition at line 46 of file Auditor.h.

Constructor & Destructor Documentation

◆ Auditor() [1/2]

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

22 : m_name( name ), m_pSvcLocator( pSvcLocator ) {}
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:133
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:135
const std::string & name() const override
Definition: Auditor.cpp:187

◆ Auditor() [2/2]

Auditor::Auditor ( const Auditor a)
delete

Member Function Documentation

◆ after() [1/4]

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

Definition at line 107 of file Auditor.cpp.

107  {
108  switch ( evt ) {
109  case Initialize:
110  afterInitialize( obj );
111  break;
112  case ReInitialize:
113  afterReinitialize( obj );
114  break;
115  case Execute:
116  afterExecute( obj, sc );
117  break;
118  case Finalize:
119  afterFinalize( obj );
120  break;
121  case Start:
122  break;
123  case Stop:
124  break;
125  case ReStart:
126  break;
127  default:
128  break; // do nothing
129  }
130 }
void afterExecute(INamedInterface *, const StatusCode &) override
Definition: Auditor.cpp:141
void afterInitialize(INamedInterface *) override
Definition: Auditor.cpp:137
void afterFinalize(INamedInterface *) override
Definition: Auditor.cpp:143
void afterReinitialize(INamedInterface *) override
Definition: Auditor.cpp:139

◆ after() [2/4]

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

Definition at line 131 of file Auditor.cpp.

131 {}

◆ after() [3/4]

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

Definition at line 133 of file Auditor.cpp.

133 {}

◆ after() [4/4]

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

Definition at line 134 of file Auditor.cpp.

134 {}

◆ afterExecute()

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

Definition at line 141 of file Auditor.cpp.

141 {}

◆ afterFinalize()

void Auditor::afterFinalize ( INamedInterface )
override

Definition at line 143 of file Auditor.cpp.

143 {}

◆ afterInitialize()

void Auditor::afterInitialize ( INamedInterface )
override

Definition at line 137 of file Auditor.cpp.

137 {}

◆ afterReinitialize()

void Auditor::afterReinitialize ( INamedInterface )
override

Definition at line 139 of file Auditor.cpp.

139 {}

◆ before() [1/4]

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

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

Definition at line 77 of file Auditor.cpp.

77  {
78  switch ( evt ) {
79  case Initialize:
80  beforeInitialize( obj );
81  break;
82  case ReInitialize:
83  beforeReinitialize( obj );
84  break;
85  case Execute:
86  beforeExecute( obj );
87  break;
88  case Finalize:
89  beforeFinalize( obj );
90  break;
91  case Start:
92  break;
93  case Stop:
94  break;
95  case ReStart:
96  break;
97  default:
98  break; // do nothing
99  }
100 }
void beforeInitialize(INamedInterface *) override
Definition: Auditor.cpp:136
void beforeExecute(INamedInterface *) override
Definition: Auditor.cpp:140
void beforeReinitialize(INamedInterface *) override
Definition: Auditor.cpp:138
void beforeFinalize(INamedInterface *) override
Definition: Auditor.cpp:142

◆ before() [2/4]

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

Definition at line 101 of file Auditor.cpp.

101 {}

◆ before() [3/4]

void Auditor::before ( CustomEventTypeRef  ,
INamedInterface  
)
override

Definition at line 103 of file Auditor.cpp.

103 {}

◆ before() [4/4]

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

Definition at line 104 of file Auditor.cpp.

104 {}

◆ beforeExecute()

void Auditor::beforeExecute ( INamedInterface )
override

Definition at line 140 of file Auditor.cpp.

140 {}

◆ beforeFinalize()

void Auditor::beforeFinalize ( INamedInterface )
override

Definition at line 142 of file Auditor.cpp.

142 {}

◆ beforeInitialize()

void Auditor::beforeInitialize ( INamedInterface )
override

Definition at line 136 of file Auditor.cpp.

136 {}

◆ beforeReinitialize()

void Auditor::beforeReinitialize ( INamedInterface )
override

Definition at line 138 of file Auditor.cpp.

138 {}

◆ finalize()

StatusCode Auditor::finalize ( )
virtual

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

Definition at line 185 of file Auditor.cpp.

185 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

◆ initialize()

StatusCode Auditor::initialize ( )
virtual

Reimplemented in Google::HeapChecker, PerfMonAuditor, TimingAuditor, Google::AuditorBase, AlgContextAuditor, IntelProfilerAuditor, MemStatAuditor, and ChronoAuditor.

Definition at line 74 of file Auditor.cpp.

74 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

◆ isEnabled()

bool Auditor::isEnabled ( ) const
override

Definition at line 189 of file Auditor.cpp.

189 { return m_isEnabled; }
Gaudi::Property< bool > m_isEnabled
Definition: Auditor.h:141

◆ name()

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

Definition at line 187 of file Auditor.cpp.

187 { return m_name; }
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:133

◆ operator=()

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

◆ service() [1/2]

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.

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  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.cpp:191
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:86
const std::string & name() const override
Definition: Auditor.cpp:187
constexpr static const auto FAILURE
Definition: StatusCode.h:97

◆ service() [2/2]

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

Definition at line 121 of file Auditor.h.

121  {
122  return serviceLocator()->service<T>( name, createIf );
123  }
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.cpp:191
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:86
const std::string & name() const override
Definition: Auditor.cpp:187

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

191 { return m_pSvcLocator; }
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:135

◆ setProperties()

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

194  {
195  if ( !m_pSvcLocator ) return StatusCode::FAILURE;
196  auto jos = service<IJobOptionsSvc>( "JobOptionsSvc" );
197  if ( !jos ) return StatusCode::FAILURE;
198 
199  // this initializes the messaging, in case property update handlers need to print
200  // and update the property value bypassing the update handler
201  m_outputLevel.value() = setUpMessaging();
202 
203  return jos->setMyProperties( name(), this );
204 }
MSG::Level setUpMessaging() const
Set up local caches.
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:135
const std::string & name() const override
Definition: Auditor.cpp:187
constexpr static const auto FAILURE
Definition: StatusCode.h:97
Gaudi::Property< int > m_outputLevel
Definition: Auditor.h:137

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

145  {
147  try {
148  //
149  // Invoke the finalize() method of the derived class if
150  // it has been initialized.
151  if ( m_isInitialized && !m_isFinalized ) {
152  m_isFinalized = true;
153  sc = finalize();
154  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
155  }
156  return sc;
157  //
158  } catch ( const GaudiException& Exception )
159  {
161  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
162  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
165  MsgStream logEx( msgSvc(), Exception.tag() );
166  logEx << MSG::ERROR << Exception << endmsg;
167  } catch ( const std::exception& Exception )
168  {
170  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
171  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
173  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
174  logEx << MSG::ERROR << Exception.what() << endmsg;
175  } catch ( ... )
176  {
178  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
179  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
180  }
182  return StatusCode::FAILURE;
183 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
virtual StatusCode finalize()
Definition: Auditor.cpp:185
Define general base for Gaudi exception.
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual const std::string & tag() const
name tag for the exception, or exception type
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:143
T what(T... args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
STL class.
const std::string & name() const override
Definition: Auditor.cpp:187
constexpr static const auto FAILURE
Definition: StatusCode.h:97
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
bool m_isFinalized
Auditor has been finalized flag.
Definition: Auditor.h:144

◆ 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  // Set the Auditor's properties
36  sc = setProperties();
37  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
38 
39  {
40  try {
41  // Invoke the initialize() method of the derived class
42  sc = initialize();
43  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
44  m_isInitialized = true;
45 
46  return sc;
47  } catch ( const GaudiException& Exception )
48  {
50  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
51  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
53  MsgStream logEx( msgSvc(), Exception.tag() );
54  logEx << MSG::ERROR << Exception << endmsg;
55  } catch ( const std::exception& Exception )
56  {
58  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
59  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
61  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
62  logEx << MSG::ERROR << Exception.what() << endmsg;
63  } catch ( ... ) {
65  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
66  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
67  }
68  }
69  }
71  return StatusCode::FAILURE;
72 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
Define general base for Gaudi exception.
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
StatusCode setProperties()
Set the auditor's properties.
Definition: Auditor.cpp:194
virtual const std::string & tag() const
name tag for the exception, or exception type
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:143
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:135
T what(T... args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
STL class.
bool isEnabled() const override
Definition: Auditor.cpp:189
const std::string & name() const override
Definition: Auditor.cpp:187
constexpr static const auto FAILURE
Definition: StatusCode.h:97
virtual StatusCode initialize()
Definition: Auditor.cpp:74
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

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

◆ m_isFinalized

bool Auditor::m_isFinalized = false
private

Auditor has been finalized flag.

Definition at line 144 of file Auditor.h.

◆ m_isInitialized

bool Auditor::m_isInitialized = false
private

Auditor has been initialized flag.

Definition at line 143 of file Auditor.h.

◆ m_name

std::string Auditor::m_name
private

Auditor's name for identification.

Definition at line 133 of file Auditor.h.

◆ m_outputLevel

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

Definition at line 137 of file Auditor.h.

◆ m_pSvcLocator

SmartIF<ISvcLocator> Auditor::m_pSvcLocator
mutableprivate

Pointer to service locator service.

Definition at line 135 of file Auditor.h.


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