| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <Gaudi/PluginService.h>
11 #include <string>
12 #include <vector>
13
14 // Forward declarations
15 class IService;
16 class IMessageSvc;
17 class Property;
18 class Algorithm;
19
34 class GAUDI_API Auditor : public implements2<IAuditor, IProperty> {
35 public:
36 typedef Gaudi::PluginService::Factory2<IAuditor*,
37 const std::string&,
38 ISvcLocator*> Factory;
39
43 Auditor( const std::string& name, ISvcLocator *svcloc );
45 virtual ~Auditor();
46
50 StatusCode sysInitialize();
54 StatusCode sysFinalize();
55
57
58 virtual void before(StandardEventType, INamedInterface*);
59 virtual void before(StandardEventType, const std::string&);
60
61 virtual void before(CustomEventTypeRef, INamedInterface*);
62 virtual void before(CustomEventTypeRef, const std::string&);
63
64 virtual void after(StandardEventType, INamedInterface*, const StatusCode&);
65 virtual void after(StandardEventType, const std::string&, const StatusCode&);
66
67 virtual void after(CustomEventTypeRef, INamedInterface*, const StatusCode&);
68 virtual void after(CustomEventTypeRef, const std::string&, const StatusCode&);
69
70 // Obsolete methods
71
72 virtual void beforeInitialize(INamedInterface* ) ;
73 virtual void afterInitialize(INamedInterface* ) ;
74
75 virtual void beforeReinitialize(INamedInterface* ) ;
76 virtual void afterReinitialize(INamedInterface* ) ;
77
78 virtual void beforeExecute(INamedInterface* );
79 virtual void afterExecute(INamedInterface*, const StatusCode& );
80
81 virtual void beforeFinalize(INamedInterface* ) ;
82 virtual void afterFinalize(INamedInterface* ) ;
83
84 virtual void beforeBeginRun(INamedInterface* );
85 virtual void afterBeginRun(INamedInterface* );
86
87 virtual void beforeEndRun(INamedInterface* );
88 virtual void afterEndRun(INamedInterface* );
89
90 virtual StatusCode initialize();
91 virtual StatusCode finalize();
92
93 virtual const std::string& name() const ;
94
95 virtual bool isEnabled() const ;
96
100 SmartIF<IMessageSvc>& msgSvc() const;
101
103 int outputLevel() const { return m_outputLevel; }
104
106 void setOutputLevel( int level );
107
112 SmartIF<ISvcLocator>& serviceLocator() const;
113
116 template <class T>
117 StatusCode service( const std::string& name, T*& svc, bool createIf = false ) const {
118 SmartIF<T> ptr(serviceLocator()->service(name, createIf));
119 if (ptr.isValid()) {
120 svc = ptr.get();
121 svc->addRef();
122 return StatusCode::SUCCESS;
123 }
124 // else
125 svc = 0;
126 return StatusCode::FAILURE;
127 }
128
130 virtual StatusCode setProperty(const Property& p);
131
133 virtual StatusCode setProperty( const std::string& s );
134
136 virtual StatusCode setProperty( const std::string& n, const std::string& v);
137
139 virtual StatusCode getProperty(Property* p) const;
140
142 virtual const Property& getProperty( const std::string& name) const;
143
145 virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
146
148 const std::vector<Property*>& getProperties( ) const;
149
150
191 template <class TYPE>
192 StatusCode setProperty
193 ( const std::string& name ,
194 const TYPE& value )
195 { return Gaudi::Utils::setProperty ( m_PropertyMgr , name , value ) ; }
196
202 StatusCode setProperties();
203
204 // ==========================================================================
232 template <class T>
233 Property* declareProperty( const std::string& name, T& property,
234 const std::string& doc = "none") const {
235 return m_PropertyMgr->declareProperty(name, property, doc);
236 }
237
238 private:
239
240 std::string m_name;
241
242 mutable SmartIF<IMessageSvc> m_MS;
243 mutable SmartIF<ISvcLocator> m_pSvcLocator;
244 PropertyMgr* m_PropertyMgr;
245 int m_outputLevel;
246 bool m_isEnabled;
247 bool m_isInitialized;
248 bool m_isFinalized;
249
250 // Private Copy constructor: NO COPY ALLOWED
251 Auditor(const Auditor& a);
252
253 // Private assignment operator: NO ASSIGNMENT ALLOWED
254 Auditor& operator=(const Auditor& rhs);
255 };
256
257 #ifndef GAUDI_NEW_PLUGIN_SERVICE
258 template <class T>
259 class AudFactory {
260 public:
261 template <typename S>
262 static typename S::ReturnType create(typename S::Arg1Type a1,
263 typename S::Arg2Type a2) {
264 return new T(a1, a2);
265 }
266 };
267
268 // Macros to declare component factories
269 #define DECLARE_AUDITOR_FACTORY(x) \
270 DECLARE_FACTORY_WITH_CREATOR(x, AudFactory< x >, Auditor::Factory)
271 #define DECLARE_NAMESPACE_AUDITOR_FACTORY(n, x) \
272 DECLARE_AUDITOR_FACTORY(n::x)
273
274 #else
275
276 // macros to declare factories
277 #define DECLARE_AUDITOR_FACTORY(x) DECLARE_COMPONENT(x)
278 #define DECLARE_NAMESPACE_AUDITOR_FACTORY(n, x) DECLARE_COMPONENT(n::x)
279
280 #endif
281
282 #endif //GAUDIKERNEL_AUDITOR_H
283