AuditorSvc Class Reference

#include <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 beforeBeginRun (INamedInterface *ini) override
 
void afterBeginRun (INamedInterface *ini) override
 
void beforeEndRun (INamedInterface *ini) override
 
void afterEndRun (INamedInterface *ini) 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
 
 AuditorSvc (const std::string &name, ISvcLocator *svc)
 
 ~AuditorSvc () override=default
 
- Public Member Functions inherited from extends< BASE, Interfaces >
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::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
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::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Member Functions

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

Private Attributes

std::vector< std::string > m_audNameList
 
std::vector< SmartIF< IAuditor > > m_pAudList
 
bool m_isEnabled = true
 

Additional Inherited Members

- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
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 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...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 

Detailed Description

Definition at line 18 of file AuditorSvc.h.

Constructor & Destructor Documentation

AuditorSvc::AuditorSvc ( const std::string &  name,
ISvcLocator svc 
)

Definition at line 82 of file AuditorSvc.cpp.

83 : base_class(name, svc) {
84  declareProperty("Auditors", m_audNameList );
85  declareProperty("Enable", m_isEnabled = true);
86 }
extends base_class
Typedef to this class.
Definition: extends.h:14
std::vector< std::string > m_audNameList
Definition: AuditorSvc.h:100
bool m_isEnabled
Definition: AuditorSvc.h:106
AuditorSvc::~AuditorSvc ( )
overridedefault

Member Function Documentation

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

Definition at line 144 of file AuditorSvc.cpp.

144  {
145  if (!isEnabled()) return;
146  for (auto& it : m_pAudList ) {
147  if(it->isEnabled()) it->after(evt,obj,sc);
148  }
149 }
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
bool isEnabled() const override
Definition: AuditorSvc.cpp:201
void AuditorSvc::after ( StandardEventType  evt,
const std::string &  name,
const StatusCode sc 
)
override

Definition at line 151 of file AuditorSvc.cpp.

151  {
152  if (!isEnabled()) return;
153  for (auto& it : m_pAudList ) {
154  if(it->isEnabled()) it->after(evt,name,sc);
155  }
156 }
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
bool isEnabled() const override
Definition: AuditorSvc.cpp:201
void AuditorSvc::after ( CustomEventTypeRef  evt,
INamedInterface obj,
const StatusCode sc 
)
override

Definition at line 158 of file AuditorSvc.cpp.

158  {
159  if (!isEnabled()) return;
160  for (auto& it : m_pAudList ) {
161  if(it->isEnabled()) it->after(evt,obj,sc);
162  }
163 }
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
bool isEnabled() const override
Definition: AuditorSvc.cpp:201
void AuditorSvc::after ( CustomEventTypeRef  evt,
const std::string &  name,
const StatusCode sc 
)
override

Definition at line 165 of file AuditorSvc.cpp.

165  {
166  if (!isEnabled()) return;
167  for (auto& it : m_pAudList) {
168  if(it->isEnabled()) it->after(evt,name,sc);
169  }
170 }
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
bool isEnabled() const override
Definition: AuditorSvc.cpp:201
void AuditorSvc::afterBeginRun ( INamedInterface ini)
override
void AuditorSvc::afterEndRun ( INamedInterface ini)
override
void AuditorSvc::afterExecute ( INamedInterface ini,
const StatusCode  
)
override

Definition at line 186 of file AuditorSvc.cpp.

186  {
187  throw GaudiException("The method afterExecute is obsolete do not call it.",
188  "AuditorSvc::afterExecute" , StatusCode::FAILURE);
189 }
Define general base for Gaudi exception.
void AuditorSvc::afterFinalize ( INamedInterface ini)
override
void AuditorSvc::afterInitialize ( INamedInterface ini)
override
void AuditorSvc::afterReinitialize ( INamedInterface ini)
override
void AuditorSvc::before ( StandardEventType  evt,
INamedInterface obj 
)
override

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

Definition at line 115 of file AuditorSvc.cpp.

115  {
116  if (!isEnabled()) return;
117  for (auto& it : m_pAudList ) {
118  if(it->isEnabled()) it->before(evt,obj);
119  }
120 }
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
bool isEnabled() const override
Definition: AuditorSvc.cpp:201
void AuditorSvc::before ( StandardEventType  evt,
const std::string &  name 
)
override

Definition at line 122 of file AuditorSvc.cpp.

122  {
123  if (!isEnabled()) return;
124  for (auto& it : m_pAudList ) {
125  if(it->isEnabled()) it->before(evt,name);
126  }
127 }
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
bool isEnabled() const override
Definition: AuditorSvc.cpp:201
void AuditorSvc::before ( CustomEventTypeRef  evt,
INamedInterface obj 
)
override

Definition at line 129 of file AuditorSvc.cpp.

129  {
130  if (!isEnabled()) return;
131  for (auto& it : m_pAudList) {
132  if(it->isEnabled()) it->before(evt,obj);
133  }
134 }
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
bool isEnabled() const override
Definition: AuditorSvc.cpp:201
void AuditorSvc::before ( CustomEventTypeRef  evt,
const std::string &  name 
)
override

Definition at line 136 of file AuditorSvc.cpp.

136  {
137  if (!isEnabled()) return;
138  for (auto& it : m_pAudList ) {
139  if(it->isEnabled()) it->before(evt,name);
140  }
141 }
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
bool isEnabled() const override
Definition: AuditorSvc.cpp:201
void AuditorSvc::beforeBeginRun ( INamedInterface ini)
override
void AuditorSvc::beforeEndRun ( INamedInterface ini)
override
void AuditorSvc::beforeExecute ( INamedInterface ini)
override
void AuditorSvc::beforeFinalize ( INamedInterface ini)
override
void AuditorSvc::beforeInitialize ( INamedInterface ini)
override
void AuditorSvc::beforeReinitialize ( INamedInterface ini)
override
StatusCode AuditorSvc::finalize ( )
override

Definition at line 103 of file AuditorSvc.cpp.

103  {
104 
105  for (auto& it : m_pAudList ) {
106  if(it->isEnabled()) it->sysFinalize().ignore();
107  }
108  m_pAudList.clear();
109 
110  // Finalize this specific service
111  return Service::finalize();
112 }
StatusCode finalize() override
Definition: Service.cpp:188
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
SmartIF< IAuditor > AuditorSvc::findAuditor_ ( const std::string &  name)
private

Definition at line 41 of file AuditorSvc.cpp.

41  {
42  // find an auditor by name, return 0 on error
43  const std::string item_name = Gaudi::Utils::TypeNameString(name).name();
44  auto it = std::find_if( std::begin(m_pAudList), std::end(m_pAudList),
45  [&](const IAuditor* i) { return i->name() == item_name; });
46  return SmartIF<IAuditor>{ it != std::end(m_pAudList) ? *it : nullptr };
47 }
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
virtual const std::string & name() const =0
Retrieve the name of the instance.
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
const std::string & name() const
list i
Definition: ana.py:128
The IAuditor is the interface implmented by the AlgAuditor base class.
Definition: IAuditor.h:18
IAuditor * AuditorSvc::getAuditor ( const std::string &  name)
override

Definition at line 213 of file AuditorSvc.cpp.

213  {
214  // by interactively setting properties, auditors might be out of sync
215  if ( !syncAuditors_().isSuccess() ) {
216  // as we didn't manage to sync auditors, the safest bet is to assume the
217  // worse...
218  // So don't let clients play with an AuditorSvc in an inconsistent state
219  return nullptr;
220  }
221 
222  // search available auditors, returns 0 on error
223  return findAuditor_( name );
224 }
SmartIF< IAuditor > findAuditor_(const std::string &)
Definition: AuditorSvc.cpp:41
StatusCode syncAuditors_()
Definition: AuditorSvc.cpp:49
StatusCode AuditorSvc::initialize ( )
override

Definition at line 91 of file AuditorSvc.cpp.

91  {
93  if ( sc.isFailure() )
94  return sc;
95 
96  // create auditor objects for all named auditors
97  sc = syncAuditors_();
98 
99  return sc;
100 }
StatusCode initialize() override
Definition: Service.cpp:63
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode syncAuditors_()
Definition: AuditorSvc.cpp:49
bool AuditorSvc::isEnabled ( ) const
override

Definition at line 201 of file AuditorSvc.cpp.

201  {
202  return m_isEnabled;
203 }
bool m_isEnabled
Definition: AuditorSvc.h:106
SmartIF< IAuditor > AuditorSvc::newAuditor_ ( MsgStream log,
const std::string &  name 
)
private

Definition at line 22 of file AuditorSvc.cpp.

22  {
23  // locate the auditor factory, instantiate a new auditor, initialize it
24  StatusCode sc;
26  SmartIF<IAuditor> aud{ Auditor::Factory::create( item.type(), item.name(), serviceLocator().get() ) };
27  if ( aud ) {
28  if ( m_targetState >= Gaudi::StateMachine::INITIALIZED ) {
29  sc = aud->sysInitialize();
30  if ( sc.isFailure() ) {
31  log << MSG::WARNING << "Failed to initialize Auditor " << name << endmsg;
32  aud.reset();
33  }
34  }
35  } else {
36  log << MSG::WARNING << "Unable to retrieve factory for Auditor " << name << endmsg;
37  }
38  return aud;
39 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
tuple item
print s1,s2
Definition: ana.py:146
StatusCode AuditorSvc::syncAuditors_ ( )
private

Definition at line 49 of file AuditorSvc.cpp.

49  {
50  if ( m_audNameList.size() == m_pAudList.size() )
51  return StatusCode::SUCCESS;
52 
53  MsgStream log( msgSvc(), name() );
54  StatusCode sc;
55 
56 // if ( sc.isFailure() ) {
57 // log << MSG::ERROR << "Unable to locate ObjectManager Service" << endmsg;
58 // return sc;
59 // }
60 
61  // create all declared Auditors that do not yet exist
62  for ( auto& it : m_audNameList ) {
63 
64  // this is clumsy, but the PropertyMgr won't tell us when my property changes right
65  // under my nose, so I'll have to figure this out the hard way
66  if ( !findAuditor_( it ) ) { // if auditor does not yet exist
67  auto aud = newAuditor_( log, it );
68  if ( aud ) {
69  m_pAudList.push_back( std::move(aud) );
70  } else {
71  log << MSG::ERROR << "Error constructing Auditor " << it << endmsg;
73  }
74  }
75  }
76  return sc;
77 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector< SmartIF< IAuditor > > m_pAudList
Definition: AuditorSvc.h:103
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IAuditor > findAuditor_(const std::string &)
Definition: AuditorSvc.cpp:41
SmartIF< IAuditor > newAuditor_(MsgStream &, const std::string &)
Definition: AuditorSvc.cpp:22
std::vector< std::string > m_audNameList
Definition: AuditorSvc.h:100
StatusCode AuditorSvc::sysFinalize ( )
override

Definition at line 208 of file AuditorSvc.cpp.

208  {
209  return Service::sysFinalize();
210 }
StatusCode sysFinalize() override
Finalize Service.
Definition: Service.cpp:153
StatusCode AuditorSvc::sysInitialize ( )
override

Definition at line 205 of file AuditorSvc.cpp.

205  {
206  return Service::sysInitialize();
207 }
StatusCode sysInitialize() override
Initialize Service.
Definition: Service.cpp:26

Member Data Documentation

std::vector<std::string> AuditorSvc::m_audNameList
private

Definition at line 100 of file AuditorSvc.h.

bool AuditorSvc::m_isEnabled = true
private

Definition at line 106 of file AuditorSvc.h.

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

Definition at line 103 of file AuditorSvc.h.


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