| The Gaudi Framework v32r1 (f65d50dc)

Auditor.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_AUDITOR_H
2 #define GAUDIKERNEL_AUDITOR_H
3
4 // Include files
5 #include "GaudiKernel/CommonMessaging.h"
6 #include "GaudiKernel/IAuditor.h"
7 #include "GaudiKernel/IProperty.h"
8 #include "GaudiKernel/IService.h"
9 #include "GaudiKernel/ISvcLocator.h" /*used by service(..)*/
10 #include "GaudiKernel/PropertyFwd.h"
11 #include "GaudiKernel/PropertyHolder.h"
12 #include <Gaudi/PluginService.h>
13 #include <string>
14 #include <vector>
15
16 // Forward declarations
17 class IService;
18 class IMessageSvc;
19
34 class GAUDI_API Auditor : public PropertyHolder<CommonMessaging<implements<IAuditor, IProperty>>> {
35 public:
36 using Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>;
37
41 Auditor( const std::string& name, ISvcLocator* svcloc );
42
43 Auditor( const Auditor& a ) = delete;
44 Auditor& operator=( const Auditor& rhs ) = delete;
45
49 StatusCode sysInitialize() override;
53 StatusCode sysFinalize() override;
54
56
57 void before( StandardEventType, INamedInterface* ) override;
58 void before( StandardEventType, const std::string& ) override;
59
60 void before( CustomEventTypeRef, INamedInterface* ) override;
61 void before( CustomEventTypeRef, const std::string& ) override;
62
63 void after( StandardEventType, INamedInterface*, const StatusCode& ) override;
64 void after( StandardEventType, const std::string&, const StatusCode& ) override;
65
66 void after( CustomEventTypeRef, INamedInterface*, const StatusCode& ) override;
67 void after( CustomEventTypeRef, const std::string&, const StatusCode& ) override;
68
69 // Obsolete methods
70
71 void beforeInitialize( INamedInterface* ) override;
72 void afterInitialize( INamedInterface* ) override;
73
74 void beforeReinitialize( INamedInterface* ) override;
75 void afterReinitialize( INamedInterface* ) override;
76
77 void beforeExecute( INamedInterface* ) override;
78 void afterExecute( INamedInterface*, const StatusCode& ) override;
79
80 void beforeFinalize( INamedInterface* ) override;
81 void afterFinalize( INamedInterface* ) override;
82
83 void beforeBeginRun( INamedInterface* ) override;
84 void afterBeginRun( INamedInterface* ) override;
85
86 void beforeEndRun( INamedInterface* ) override;
87 void afterEndRun( INamedInterface* ) override;
88
89 virtual StatusCode initialize();
90 virtual StatusCode finalize();
91
92 const std::string& name() const override;
93
94 bool isEnabled() const override;
95
100 SmartIF<ISvcLocator>& serviceLocator() const override;
101
104 template <class T>
105 StatusCode service( const std::string& name, T*& svc, bool createIf = false ) const {
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 }
115
116 template <class T = IService>
117 SmartIF<T> service( const std::string& name, bool createIf = false ) const {
118 return serviceLocator()->service<T>( name, createIf );
119 }
120
126 StatusCode setProperties();
127
128 private:
129 std::string m_name;
130
131 mutable SmartIF<ISvcLocator> m_pSvcLocator;
132
133 Gaudi::Property<int> m_outputLevel{
134 this, "OutputLevel", MSG::NIL,
135 [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); },
136 "output level"};
137 Gaudi::Property<bool> m_isEnabled{this, "Enable", true, "should the auditor be used or not"};
138
139 bool m_isInitialized = false;
140 bool m_isFinalized = false;
141 };
142
143 #endif // GAUDIKERNEL_AUDITOR_H
PropertyHolder.h
SmartIF< ISvcLocator >
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
Auditor::service
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.
Definition: Auditor.h:105
IAuditor.h
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Auditor::m_name
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:129
std::string
STL class.
PropertyFwd.h
Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:131
Auditor::Factory
Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)> Factory
Definition: Auditor.h:36
IService
General service interface definition.
Definition: IService.h:18
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
PropertyHolder::operator=
PropertyHolder & operator=(const PropertyHolder &)=delete
CommonMessaging.h
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:37
MSG::NIL
Definition: IMessageSvc.h:15
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
IService.h
PluginService.h
INamedInterface
IInterface compliant class extending IInterface with the name() method.
Definition: INamedInterface.h:15
IProperty.h
Auditor::service
SmartIF< T > service(const std::string &name, bool createIf=false) const
Definition: Auditor.h:117
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:71
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
IAuditor
The IAuditor is the interface implmented by the AlgAuditor base class.
Definition: IAuditor.h:18
ISvcLocator.h
Auditor
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:34