| The Gaudi Framework v29r1 (5cd95fa2)

- 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/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 class Algorithm;
20
35 class GAUDI_API Auditor : public PropertyHolder<CommonMessaging<implements<IAuditor, IProperty>>>
36 {
37 public:
38 #ifndef __REFLEX__
39 typedef Gaudi::PluginService::Factory<IAuditor*, const std::string&, ISvcLocator*> Factory;
40 #endif
41
45 Auditor( const std::string& name, ISvcLocator* svcloc );
46
47 Auditor( const Auditor& a ) = delete;
48 Auditor& operator=( const Auditor& rhs ) = delete;
49
53 StatusCode sysInitialize() override;
57 StatusCode sysFinalize() override;
58
60
61 void before( StandardEventType, INamedInterface* ) override;
62 void before( StandardEventType, const std::string& ) override;
63
64 void before( CustomEventTypeRef, INamedInterface* ) override;
65 void before( CustomEventTypeRef, const std::string& ) override;
66
67 void after( StandardEventType, INamedInterface*, const StatusCode& ) override;
68 void after( StandardEventType, const std::string&, const StatusCode& ) override;
69
70 void after( CustomEventTypeRef, INamedInterface*, const StatusCode& ) override;
71 void after( CustomEventTypeRef, const std::string&, const StatusCode& ) override;
72
73 // Obsolete methods
74
75 void beforeInitialize( INamedInterface* ) override;
76 void afterInitialize( INamedInterface* ) override;
77
78 void beforeReinitialize( INamedInterface* ) override;
79 void afterReinitialize( INamedInterface* ) override;
80
81 void beforeExecute( INamedInterface* ) override;
82 void afterExecute( INamedInterface*, const StatusCode& ) override;
83
84 void beforeFinalize( INamedInterface* ) override;
85 void afterFinalize( INamedInterface* ) override;
86
87 void beforeBeginRun( INamedInterface* ) override;
88 void afterBeginRun( INamedInterface* ) override;
89
90 void beforeEndRun( INamedInterface* ) override;
91 void afterEndRun( INamedInterface* ) override;
92
93 virtual StatusCode initialize();
94 virtual StatusCode finalize();
95
96 const std::string& name() const override;
97
98 bool isEnabled() const override;
99
104 SmartIF<ISvcLocator>& serviceLocator() const override;
105
108 template <class T>
109 StatusCode service( const std::string& name, T*& svc, bool createIf = false ) const
110 {
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 {
124 return serviceLocator()->service<T>( name, createIf );
125 }
126
132 StatusCode setProperties();
133
134 private:
135 std::string m_name;
136
137 mutable SmartIF<ISvcLocator> m_pSvcLocator;
138
139 Gaudi::Property<int> m_outputLevel{this, "OutputLevel", MSG::NIL, "output level"};
140 Gaudi::Property<bool> m_isEnabled{this, "Enable", true, "should the auditor be used or not"};
141
142 bool m_isInitialized = false;
143 bool m_isFinalized = false;
144 };
145
146 #ifndef GAUDI_NEW_PLUGIN_SERVICE
147 template <class T>
148 class AudFactory
149 {
150 public:
151 #ifndef __REFLEX__
152 template <typename S, typename... Args>
153 static typename S::ReturnType create( Args&&... args )
154 {
155 return new T( std::forward<Args>( args )... );
156 }
157 #endif
158 };
159
160 // Macros to declare component factories
161 #define DECLARE_AUDITOR_FACTORY( x ) DECLARE_FACTORY_WITH_CREATOR( x, AudFactory<x>, Auditor::Factory )
162 #define DECLARE_NAMESPACE_AUDITOR_FACTORY( n, x ) DECLARE_AUDITOR_FACTORY( n::x )
163
164 #else
165
166 // macros to declare factories
167 #define DECLARE_AUDITOR_FACTORY( x ) DECLARE_COMPONENT( x )
168 #define DECLARE_NAMESPACE_AUDITOR_FACTORY( n, x ) DECLARE_COMPONENT( n::x )
169
170 #endif
171
172 #endif // GAUDIKERNEL_AUDITOR_H
PropertyHolder.h
StatusCode::SUCCESS
Definition: StatusCode.h:31
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&#39;t already exist.
Definition: Auditor.h:109
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:32
StatusCode::FAILURE
Definition: StatusCode.h:31
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
gaudirun.args
args
Definition: gaudirun.py:244
IAuditor.h
Auditor::m_name
std::string m_name
Auditor&#39;s name for identification.
Definition: Auditor.h:135
std::string
STL class.
PropertyFwd.h
Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:137
Auditor::Factory
Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
Definition: Auditor.h:39
IService
General service interface definition.
Definition: IService.h:18
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
PropertyHolder::operator=
PropertyHolder & operator=(const PropertyHolder &)=delete
AudFactory
Definition: Auditor.h:148
CommonMessaging.h
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
MSG::NIL
Definition: IMessageSvc.h:16
IService.h
PluginService.h
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
INamedInterface
IInterface compliant class extending IInterface with the name() method.
Definition: INamedInterface.h:15
IProperty.h
Gaudi::PluginService::Factory
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginService.h:45
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:73
AudFactory::create
static S::ReturnType create(Args &&...args)
Definition: Auditor.h:153
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
ISvcLocator.h
Auditor::service
SmartIF< T > service(const std::string &name, bool createIf=false) const
Definition: Auditor.h:122
Auditor
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:35