The Gaudi Framework  master (37c0b60a)
AuditorSvc Class Reference

#include </builds/gaudi/Gaudi/GaudiCommonSvc/src/AuditorSvc.h>

Inheritance diagram for AuditorSvc:
Collaboration diagram for AuditorSvc:

Public Member Functions

StatusCode initialize () override
 
StatusCode finalize () override
 
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 *ini) override
 
void afterInitialize (INamedInterface *ini) override
 
void beforeReinitialize (INamedInterface *ini) override
 
void afterReinitialize (INamedInterface *ini) override
 
void beforeExecute (INamedInterface *ini) override
 
void afterExecute (INamedInterface *ini, const StatusCode &) override
 
void beforeFinalize (INamedInterface *ini) override
 
void afterFinalize (INamedInterface *ini) override
 
bool isEnabled () const override
 
StatusCode sysInitialize () override
 
StatusCode sysFinalize () override
 
IAuditorgetAuditor (const std::string &name) override
 
- Public Member Functions inherited from extends< Service, IAuditorSvc >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service
More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service
More...
 
StatusCode sysStart () override
 Initialize Service
More...
 
StatusCode sysStop () override
 Initialize Service
More...
 
StatusCode sysFinalize () override
 Finalize Service
More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator
More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 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< IService, IProperty, IStateful > >
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 Member Functions

SmartIF< IAuditornewAuditor_ (MsgStream &, std::string_view)
 
SmartIF< IAuditorfindAuditor_ (std::string_view)
 
StatusCode syncAuditors_ ()
 

Private Attributes

Gaudi::Property< std::vector< std::string > > m_audNameList
 
Gaudi::Property< bool > m_isEnabled { this, "Enable", true, "enable/disable alltogether the auditors" }
 
std::vector< SmartIF< IAuditor > > m_pAudList
 

Additional Inherited Members

- Public Types inherited from extends< Service, IAuditorSvc >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 Standard Destructor
More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
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...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditInit { this, "AuditServices", false, "[[deprecated]] unused" }
 
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
 
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
 
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
 
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
 
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
 
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service
More...
 

Detailed Description

Definition at line 28 of file AuditorSvc.h.

Member Function Documentation

◆ after() [1/4]

void AuditorSvc::after ( CustomEventTypeRef  evt,
const std::string name,
const StatusCode sc 
)
override

Definition at line 164 of file AuditorSvc.cpp.

164  {
165  if ( !isEnabled() ) return;
166  for ( auto& it : m_pAudList ) {
167  if ( it->isEnabled() ) it->after( evt, name, sc );
168  }
169 }

◆ after() [2/4]

void AuditorSvc::after ( CustomEventTypeRef  evt,
INamedInterface obj,
const StatusCode sc 
)
override

Definition at line 157 of file AuditorSvc.cpp.

157  {
158  if ( !isEnabled() ) return;
159  for ( auto& it : m_pAudList ) {
160  if ( it->isEnabled() ) it->after( evt, obj, sc );
161  }
162 }

◆ after() [3/4]

void AuditorSvc::after ( StandardEventType  evt,
const std::string name,
const StatusCode sc 
)
override

Definition at line 150 of file AuditorSvc.cpp.

150  {
151  if ( !isEnabled() ) return;
152  for ( auto& it : m_pAudList ) {
153  if ( it->isEnabled() ) it->after( evt, name, sc );
154  }
155 }

◆ after() [4/4]

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

Definition at line 143 of file AuditorSvc.cpp.

143  {
144  if ( !isEnabled() ) return;
145  for ( auto& it : m_pAudList ) {
146  if ( it->isEnabled() ) it->after( evt, obj, sc );
147  }
148 }

◆ afterExecute()

void AuditorSvc::afterExecute ( INamedInterface ini,
const StatusCode  
)
override

Definition at line 185 of file AuditorSvc.cpp.

185  {
186  throw GaudiException( "The method afterExecute is obsolete do not call it.", "AuditorSvc::afterExecute",
188 }

◆ afterFinalize()

void AuditorSvc::afterFinalize ( INamedInterface ini)
override

◆ afterInitialize()

void AuditorSvc::afterInitialize ( INamedInterface ini)
override

◆ afterReinitialize()

void AuditorSvc::afterReinitialize ( INamedInterface ini)
override

◆ before() [1/4]

void AuditorSvc::before ( CustomEventTypeRef  evt,
const std::string name 
)
override

Definition at line 135 of file AuditorSvc.cpp.

135  {
136  if ( !isEnabled() ) return;
137  for ( auto& it : m_pAudList ) {
138  if ( it->isEnabled() ) it->before( evt, name );
139  }
140 }

◆ before() [2/4]

void AuditorSvc::before ( CustomEventTypeRef  evt,
INamedInterface obj 
)
override

Definition at line 128 of file AuditorSvc.cpp.

128  {
129  if ( !isEnabled() ) return;
130  for ( auto& it : m_pAudList ) {
131  if ( it->isEnabled() ) it->before( evt, obj );
132  }
133 }

◆ before() [3/4]

void AuditorSvc::before ( StandardEventType  evt,
const std::string name 
)
override

Definition at line 121 of file AuditorSvc.cpp.

121  {
122  if ( !isEnabled() ) return;
123  for ( auto& it : m_pAudList ) {
124  if ( it->isEnabled() ) it->before( evt, name );
125  }
126 }

◆ before() [4/4]

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

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

Definition at line 114 of file AuditorSvc.cpp.

114  {
115  if ( !isEnabled() ) return;
116  for ( auto& it : m_pAudList ) {
117  if ( it->isEnabled() ) it->before( evt, obj );
118  }
119 }

◆ beforeExecute()

void AuditorSvc::beforeExecute ( INamedInterface ini)
override

◆ beforeFinalize()

void AuditorSvc::beforeFinalize ( INamedInterface ini)
override

◆ beforeInitialize()

void AuditorSvc::beforeInitialize ( INamedInterface ini)
override

◆ beforeReinitialize()

void AuditorSvc::beforeReinitialize ( INamedInterface ini)
override

◆ finalize()

StatusCode AuditorSvc::finalize ( )
override

Definition at line 102 of file AuditorSvc.cpp.

102  {
103 
104  for ( auto& it : m_pAudList ) {
105  if ( it->isEnabled() ) it->sysFinalize().ignore();
106  }
107  m_pAudList.clear();
108 
109  // Finalize this specific service
110  return Service::finalize();
111 }

◆ findAuditor_()

SmartIF< IAuditor > AuditorSvc::findAuditor_ ( std::string_view  name)
private

Definition at line 51 of file AuditorSvc.cpp.

51  {
52  // find an auditor by name, return 0 on error
54  [item_name = Gaudi::Utils::TypeNameString( name ).name()]( const IAuditor* i ) {
55  return i->name() == item_name;
56  } );
57  return SmartIF<IAuditor>{ it != std::end( m_pAudList ) ? *it : nullptr };
58 }

◆ getAuditor()

IAuditor * AuditorSvc::getAuditor ( const std::string name)
override

Definition at line 198 of file AuditorSvc.cpp.

198  {
199  // by interactively setting properties, auditors might be out of sync
200  if ( !syncAuditors_().isSuccess() ) {
201  // as we didn't manage to sync auditors, the safest bet is to assume the
202  // worse...
203  // So don't let clients play with an AuditorSvc in an inconsistent state
204  return nullptr;
205  }
206 
207  // search available auditors, returns 0 on error
208  return findAuditor_( name );
209 }

◆ initialize()

StatusCode AuditorSvc::initialize ( )
override

Definition at line 91 of file AuditorSvc.cpp.

91  {
93  if ( sc.isFailure() ) return sc;
94 
95  // create auditor objects for all named auditors
96  sc = syncAuditors_();
97 
98  return sc;
99 }

◆ isEnabled()

bool AuditorSvc::isEnabled ( ) const
override

Definition at line 193 of file AuditorSvc.cpp.

193 { return m_isEnabled; }

◆ newAuditor_()

SmartIF< IAuditor > AuditorSvc::newAuditor_ ( MsgStream log,
std::string_view  name 
)
private

Definition at line 32 of file AuditorSvc.cpp.

32  {
33  // locate the auditor factory, instantiate a new auditor, initialize it
34  StatusCode sc;
36  SmartIF<IAuditor> aud{ Auditor::Factory::create( item.type(), item.name(), serviceLocator().get() ).release() };
37  if ( aud ) {
39  sc = aud->sysInitialize();
40  if ( sc.isFailure() ) {
41  log << MSG::WARNING << "Failed to initialize Auditor " << name << endmsg;
42  aud.reset();
43  }
44  }
45  } else {
46  log << MSG::WARNING << "Unable to retrieve factory for Auditor " << name << endmsg;
47  }
48  return aud;
49 }

◆ syncAuditors_()

StatusCode AuditorSvc::syncAuditors_ ( )
private

Definition at line 60 of file AuditorSvc.cpp.

60  {
61  if ( m_audNameList.size() == m_pAudList.size() ) return StatusCode::SUCCESS;
62 
63  StatusCode sc;
64 
65  // if ( sc.isFailure() ) {
66  // error() << "Unable to locate ObjectManager Service" << endmsg;
67  // return sc;
68  // }
69 
70  // create all declared Auditors that do not yet exist
71  for ( auto& it : m_audNameList ) {
72 
73  // this is clumsy, but the PropertyHolder won't tell us when my property changes right
74  // under my nose, so I'll have to figure this out the hard way
75  if ( !findAuditor_( it ) ) { // if auditor does not yet exist
76  auto aud = newAuditor_( msgStream(), it );
77  if ( aud ) {
78  m_pAudList.push_back( std::move( aud ) );
79  } else {
80  error() << "Error constructing Auditor " << it << endmsg;
82  }
83  }
84  }
85  return sc;
86 }

◆ sysFinalize()

StatusCode AuditorSvc::sysFinalize ( )
override

Definition at line 196 of file AuditorSvc.cpp.

196 { return Service::sysFinalize(); }

◆ sysInitialize()

StatusCode AuditorSvc::sysInitialize ( )
override

Definition at line 195 of file AuditorSvc.cpp.

195 { return Service::sysInitialize(); }

Member Data Documentation

◆ m_audNameList

Gaudi::Property<std::vector<std::string> > AuditorSvc::m_audNameList
private
Initial value:
{
this, "Auditors", {}, "list of auditors names", "OrderedSet<std::string>" }

Definition at line 90 of file AuditorSvc.h.

◆ m_isEnabled

Gaudi::Property<bool> AuditorSvc::m_isEnabled { this, "Enable", true, "enable/disable alltogether the auditors" }
private

Definition at line 92 of file AuditorSvc.h.

◆ m_pAudList

std::vector<SmartIF<IAuditor> > AuditorSvc::m_pAudList
private

Definition at line 95 of file AuditorSvc.h.


The documentation for this class was generated from the following files:
IOTest.evt
evt
Definition: IOTest.py:107
AuditorSvc::m_isEnabled
Gaudi::Property< bool > m_isEnabled
Definition: AuditorSvc.h:92
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
Service::sysInitialize
StatusCode sysInitialize() override
Initialize Service
Definition: Service.cpp:34
Gaudi.Configuration.log
log
Definition: Configuration.py:28
AuditorSvc::syncAuditors_
StatusCode syncAuditors_()
Definition: AuditorSvc.cpp:60
std::move
T move(T... args)
AuditorSvc::m_pAudList
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:95
std::find_if
T find_if(T... args)
std::vector::size
T size(T... args)
GaudiException
Definition: GaudiException.h:31
GaudiPartProp.decorators.get
get
decorate the vector of properties
Definition: decorators.py:283
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
MSG::WARNING
@ WARNING
Definition: IMessageSvc.h:25
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
std::vector::clear
T clear(T... args)
std::vector::push_back
T push_back(T... args)
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:20
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
AuditorSvc::isEnabled
bool isEnabled() const override
Definition: AuditorSvc.cpp:193
SmartIF< IAuditor >
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
AuditorSvc::newAuditor_
SmartIF< IAuditor > newAuditor_(MsgStream &, std::string_view)
Definition: AuditorSvc.cpp:32
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Service::sysFinalize
StatusCode sysFinalize() override
Finalize Service
Definition: Service.cpp:193
std::begin
T begin(T... args)
Gaudi::StateMachine::INITIALIZED
@ INITIALIZED
Definition: StateMachine.h:25
AuditorSvc::m_audNameList
Gaudi::Property< std::vector< std::string > > m_audNameList
Definition: AuditorSvc.h:90
Service::m_targetState
Gaudi::StateMachine::State m_targetState
Service state
Definition: Service.h:205
AuditorSvc::findAuditor_
SmartIF< IAuditor > findAuditor_(std::string_view)
Definition: AuditorSvc.cpp:51
std::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
IAuditor
Definition: IAuditor.h:28
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
Definition: Service.cpp:335