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
6 #include "GaudiKernel/IAuditor.h"
7 #include "GaudiKernel/IService.h"
8 #include "GaudiKernel/ISvcLocator.h" /*used by service(..)*/
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 #ifndef __REFLEX__
38  const std::string&,
40 #endif
41 
45  Auditor( const std::string& name, ISvcLocator *svcloc );
47  virtual ~Auditor();
48 
52  StatusCode sysInitialize();
56  StatusCode sysFinalize();
57 
59 
60  virtual void before(StandardEventType, INamedInterface*);
61  virtual void before(StandardEventType, const std::string&);
62 
63  virtual void before(CustomEventTypeRef, INamedInterface*);
64  virtual void before(CustomEventTypeRef, const std::string&);
65 
66  virtual void after(StandardEventType, INamedInterface*, const StatusCode&);
67  virtual void after(StandardEventType, const std::string&, const StatusCode&);
68 
69  virtual void after(CustomEventTypeRef, INamedInterface*, const StatusCode&);
70  virtual void after(CustomEventTypeRef, const std::string&, const StatusCode&);
71 
72  // Obsolete methods
73 
74  virtual void beforeInitialize(INamedInterface* ) ;
75  virtual void afterInitialize(INamedInterface* ) ;
76 
77  virtual void beforeReinitialize(INamedInterface* ) ;
78  virtual void afterReinitialize(INamedInterface* ) ;
79 
80  virtual void beforeExecute(INamedInterface* );
81  virtual void afterExecute(INamedInterface*, const StatusCode& );
82 
83  virtual void beforeFinalize(INamedInterface* ) ;
84  virtual void afterFinalize(INamedInterface* ) ;
85 
86  virtual void beforeBeginRun(INamedInterface* );
87  virtual void afterBeginRun(INamedInterface* );
88 
89  virtual void beforeEndRun(INamedInterface* );
90  virtual void afterEndRun(INamedInterface* );
91 
92  virtual StatusCode initialize();
93  virtual StatusCode finalize();
94 
95  virtual const std::string& name() const ;
96 
97  virtual bool isEnabled() const ;
98 
102  SmartIF<IMessageSvc>& msgSvc() const;
103 
105  int outputLevel() const { return m_outputLevel; }
106 
108  void setOutputLevel( int level );
109 
114  SmartIF<ISvcLocator>& serviceLocator() const;
115 
118  template <class T>
119  StatusCode service( const std::string& name, T*& svc, bool createIf = false ) const {
120  SmartIF<T> ptr(serviceLocator()->service(name, createIf));
121  if (ptr.isValid()) {
122  svc = ptr.get();
123  svc->addRef();
124  return StatusCode::SUCCESS;
125  }
126  // else
127  svc = 0;
128  return StatusCode::FAILURE;
129  }
130 
132  virtual StatusCode setProperty(const Property& p);
133 
135  virtual StatusCode setProperty( const std::string& s );
136 
138  virtual StatusCode setProperty( const std::string& n, const std::string& v);
139 
141  virtual StatusCode getProperty(Property* p) const;
142 
144  virtual const Property& getProperty( const std::string& name) const;
145 
147  virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
148 
150  const std::vector<Property*>& getProperties( ) const;
151 
152 
193  template <class TYPE>
195  ( const std::string& name ,
196  const TYPE& value )
197  { return Gaudi::Utils::setProperty ( m_PropertyMgr , name , value ) ; }
198 
204  StatusCode setProperties();
205 
206  // ==========================================================================
234  template <class T>
235  Property* declareProperty( const std::string& name, T& property,
236  const std::string& doc = "none") const {
237  return m_PropertyMgr->declareProperty(name, property, doc);
238  }
239 
240  private:
241 
242  std::string m_name;
243 
248  bool m_isEnabled;
251 
252  // Private Copy constructor: NO COPY ALLOWED
253  Auditor(const Auditor& a);
254 
255  // Private assignment operator: NO ASSIGNMENT ALLOWED
256  Auditor& operator=(const Auditor& rhs);
257 };
258 
259 #ifndef GAUDI_NEW_PLUGIN_SERVICE
260 template <class T>
261 class AudFactory {
262 public:
263 #ifndef __REFLEX__
264  template <typename S, typename... Args>
265  static typename S::ReturnType create(Args... args) {
266  return new T(args...);
267  }
268 #endif
269 };
270 
271 // Macros to declare component factories
272 #define DECLARE_AUDITOR_FACTORY(x) \
273  DECLARE_FACTORY_WITH_CREATOR(x, AudFactory< x >, Auditor::Factory)
274 #define DECLARE_NAMESPACE_AUDITOR_FACTORY(n, x) \
275  DECLARE_AUDITOR_FACTORY(n::x)
276 
277 #else
278 
279 // macros to declare factories
280 #define DECLARE_AUDITOR_FACTORY(x) DECLARE_COMPONENT(x)
281 #define DECLARE_NAMESPACE_AUDITOR_FACTORY(n, x) DECLARE_COMPONENT(n::x)
282 
283 #endif
284 
285 #endif //GAUDIKERNEL_AUDITOR_H
286 
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:1212
bool m_isEnabled
Auditor is enabled flag.
Definition: Auditor.h:248
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:119
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
StandardEventType
Defines the standard (= used by the framework) auditable event types.
Definition: IAuditor.h:24
Base class used to implement the interfaces.
Definition: implements.h:150
const CustomEventType & CustomEventTypeRef
Used in function calls for optimization purposes.
Definition: IAuditor.h:41
GAUDI_API Property * getProperty(const IProperty *p, const std::string &name)
simple function which gets the property with given name from the component
Definition: Property.cpp:349
Property manager helper class.
Definition: PropertyMgr.h:38
std::string m_name
Auditor's name for identification.
Definition: Auditor.h:242
SmartIF< IMessageSvc > m_MS
Message service.
Definition: Auditor.h:244
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Auditor.h:235
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:249
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:245
Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
Definition: Auditor.h:39
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:51
General service interface definition.
Definition: IService.h:19
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:62
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
IInterface compliant class extending IInterface with the name() method.
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
list args
Definition: gaudirun.py:254
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginService.h:47
PropertyMgr * m_PropertyMgr
For management of properties.
Definition: Auditor.h:246
string s
Definition: gaudirun.py:210
int outputLevel() const
Retrieve the output level of current auditor.
Definition: Auditor.h:105
static S::ReturnType create(Args...args)
Definition: Auditor.h:265
#define GAUDI_API
Definition: Kernel.h:108
The IAuditor is the interface implmented by the AlgAuditor base class.
Definition: IAuditor.h:18
int m_outputLevel
Auditor output level.
Definition: Auditor.h:247
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:34
bool m_isFinalized
Auditor has been finalized flag.
Definition: Auditor.h:250