| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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/IProperty.h"
6 #include "GaudiKernel/IAuditor.h"
7 #include "GaudiKernel/IService.h"
8 #include "GaudiKernel/ISvcLocator.h" /*used by service(..)*/
9 #include "GaudiKernel/PropertyMgr.h"
10 #include "GaudiKernel/CommonMessaging.h"
11 #include <Gaudi/PluginService.h>
12 #include <string>
13 #include <vector>
14
15 // Forward declarations
16 class IService;
17 class IMessageSvc;
18 class Property;
19 class Algorithm;
20
35 class GAUDI_API Auditor : public CommonMessaging<implements<IAuditor,
36 IProperty>> {
37 public:
38 #ifndef __REFLEX__
39 typedef Gaudi::PluginService::Factory<IAuditor*,
40 const std::string&,
41 ISvcLocator*> Factory;
42 #endif
43
47 Auditor( const std::string& name, ISvcLocator *svcloc );
49 ~Auditor() override = default;
50
54 StatusCode sysInitialize() override;
58 StatusCode sysFinalize() override;
59
61
62 void before(StandardEventType, INamedInterface*) override;
63 void before(StandardEventType, const std::string&) override;
64
65 void before(CustomEventTypeRef, INamedInterface*) override;
66 void before(CustomEventTypeRef, const std::string&) override;
67
68 void after(StandardEventType, INamedInterface*, const StatusCode&) override;
69 void after(StandardEventType, const std::string&, const StatusCode&) override;
70
71 void after(CustomEventTypeRef, INamedInterface*, const StatusCode&) override;
72 void after(CustomEventTypeRef, const std::string&, const StatusCode&) override;
73
74 // Obsolete methods
75
76 void beforeInitialize(INamedInterface* ) override;
77 void afterInitialize(INamedInterface* ) override;
78
79 void beforeReinitialize(INamedInterface* ) override;
80 void afterReinitialize(INamedInterface* ) override;
81
82 void beforeExecute(INamedInterface* ) override;
83 void afterExecute(INamedInterface*, const StatusCode& ) override;
84
85 void beforeFinalize(INamedInterface* ) override;
86 void afterFinalize(INamedInterface* ) override;
87
88 void beforeBeginRun(INamedInterface* ) override;
89 void afterBeginRun(INamedInterface* ) override;
90
91 void beforeEndRun(INamedInterface* ) override;
92 void afterEndRun(INamedInterface* ) override;
93
94 virtual StatusCode initialize();
95 virtual StatusCode finalize();
96
97 const std::string& name() const override;
98
99 bool isEnabled() const override;
100
105 SmartIF<ISvcLocator>& serviceLocator() const;
106
109 template <class T>
110 StatusCode service( const std::string& name, T*& svc, bool createIf = false ) const {
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 }
120
121 template <class T = IService>
122 SmartIF<T> service( const std::string& name, bool createIf = false ) const {
123 return serviceLocator()->service<T>(name, createIf);
124 }
125
127 StatusCode setProperty(const Property& p) override;
128
130 StatusCode setProperty( const std::string& s ) override;
131
133 StatusCode setProperty( const std::string& n, const std::string& v) override;
134
136 StatusCode getProperty(Property* p) const override;
137
139 const Property& getProperty( const std::string& name) const override;
140
142 StatusCode getProperty( const std::string& n, std::string& v ) const override;
143
145 const std::vector<Property*>& getProperties( ) const override;
146
148 bool hasProperty(const std::string& name) const override;
149
190 template <class TYPE>
191 StatusCode setProperty
192 ( const std::string& name ,
193 const TYPE& value )
194 { return Gaudi::Utils::setProperty ( m_PropertyMgr.get() , name , value ) ; }
195
201 StatusCode setProperties();
202
203 // ==========================================================================
231 template <class T>
232 Property* declareProperty( const std::string& name, T& property,
233 const std::string& doc = "none") const {
234 return m_PropertyMgr->declareProperty(name, property, doc);
235 }
236
237 private:
238
239 std::string m_name;
240
241 mutable SmartIF<ISvcLocator> m_pSvcLocator;
242 SmartIF<PropertyMgr> m_PropertyMgr;
243 int m_outputLevel;
244 bool m_isEnabled;
245 bool m_isInitialized;
246 bool m_isFinalized;
247
248 // Private Copy constructor: NO COPY ALLOWED
249 Auditor(const Auditor& a);
250
251 // Private assignment operator: NO ASSIGNMENT ALLOWED
252 Auditor& operator=(const Auditor& rhs);
253 };
254
255 #ifndef GAUDI_NEW_PLUGIN_SERVICE
256 template <class T>
257 class AudFactory {
258 public:
259 #ifndef __REFLEX__
260 template <typename S, typename... Args>
261 static typename S::ReturnType create(Args&&... args) {
262 return new T(std::forward<Args>(args)...);
263 }
264 #endif
265 };
266
267 // Macros to declare component factories
268 #define DECLARE_AUDITOR_FACTORY(x) \
269 DECLARE_FACTORY_WITH_CREATOR(x, AudFactory< x >, Auditor::Factory)
270 #define DECLARE_NAMESPACE_AUDITOR_FACTORY(n, x) \
271 DECLARE_AUDITOR_FACTORY(n::x)
272
273 #else
274
275 // macros to declare factories
276 #define DECLARE_AUDITOR_FACTORY(x) DECLARE_COMPONENT(x)
277 #define DECLARE_NAMESPACE_AUDITOR_FACTORY(n, x) DECLARE_COMPONENT(n::x)
278
279 #endif
280
281 #endif //GAUDIKERNEL_AUDITOR_H
282
Gaudi::Utils::setProperty
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Definition: Property.h:1187
Auditor::m_isEnabled
bool m_isEnabled
Auditor is enabled flag.
Definition: Auditor.h:244
SmartIF< ISvcLocator >
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:110
AnalysisTest.initialize
def initialize()
Definition: AnalysisTest.py:12
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:28
IAuditor.h
Gaudi::Utils::hasProperty
GAUDI_API bool hasProperty(const IProperty *p, const std::string &name)
simple function which check the existence of the property with the given name.
Definition: Property.cpp:159
getProperty
const char *PyHelper() getProperty(IInterface *p, char *name)
Definition: Bootstrap.cpp:258
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
Auditor::m_name
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:239
std::string
STL class.
Auditor::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Auditor.h:232
Auditor::m_isInitialized
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:245
Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:241
Auditor::Factory
Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
Definition: Auditor.h:41
StatusCode::FAILURE
Definition: StatusCode.h:29
IService
General service interface definition.
Definition: IService.h:18
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
AudFactory
Definition: Auditor.h:257
CommonMessaging.h
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
setProperty
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:254
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
IService.h
PluginService.h
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
INamedInterface
IInterface compliant class extending IInterface with the name() method.
Definition: INamedInterface.h:15
IProperty.h
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
std::vector< Property * >
gaudirun.args
list args
Definition: gaudirun.py:290
Gaudi::PluginService::Factory
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginService.h:47
Auditor::m_PropertyMgr
SmartIF< PropertyMgr > m_PropertyMgr
For management of properties.
Definition: Auditor.h:242
PropertyMgr.h
gaudirun.s
string s
Definition: gaudirun.py:245
AudFactory::create
static S::ReturnType create(Args &&...args)
Definition: Auditor.h:261
CommonMessaging
Definition: CommonMessaging.h:58
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
IAuditor
The IAuditor is the interface implmented by the AlgAuditor base class.
Definition: IAuditor.h:18
ISvcLocator.h
Auditor::service
SmartIF< T > service(const std::string &name, bool createIf=false) const
Definition: Auditor.h:122
Auditor::m_outputLevel
int m_outputLevel
Auditor output level.
Definition: Auditor.h:243
Auditor
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:35
Auditor::m_isFinalized
bool m_isFinalized
Auditor has been finalized flag.
Definition: Auditor.h:246