File indexing completed on 2025-02-21 10:00:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIKERNEL_AUDITOR_H
0012 #define GAUDIKERNEL_AUDITOR_H
0013
0014
0015 #include "GaudiKernel/CommonMessaging.h"
0016 #include "GaudiKernel/IAuditor.h"
0017 #include "GaudiKernel/IProperty.h"
0018 #include "GaudiKernel/IService.h"
0019 #include "GaudiKernel/ISvcLocator.h" /*used by service(..)*/
0020 #include "GaudiKernel/PropertyHolder.h"
0021 #include <Gaudi/PluginService.h>
0022 #include <Gaudi/PropertyFwd.h>
0023 #include <string>
0024 #include <vector>
0025
0026
0027 class IService;
0028 class IMessageSvc;
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 class GAUDI_API Auditor : public PropertyHolder<CommonMessaging<implements<IAuditor, IProperty>>> {
0045 public:
0046 using Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>;
0047
0048
0049
0050
0051 Auditor( std::string name, ISvcLocator* svcloc );
0052
0053 Auditor( const Auditor& a ) = delete;
0054 Auditor& operator=( const Auditor& rhs ) = delete;
0055
0056
0057
0058
0059 StatusCode sysInitialize() override;
0060
0061
0062
0063 StatusCode sysFinalize() override;
0064
0065
0066
0067 void before( StandardEventType, INamedInterface* ) override;
0068 void before( StandardEventType, const std::string& ) override;
0069
0070 void before( CustomEventTypeRef, INamedInterface* ) override;
0071 void before( CustomEventTypeRef, const std::string& ) override;
0072
0073 void after( StandardEventType, INamedInterface*, const StatusCode& ) override;
0074 void after( StandardEventType, const std::string&, const StatusCode& ) override;
0075
0076 void after( CustomEventTypeRef, INamedInterface*, const StatusCode& ) override;
0077 void after( CustomEventTypeRef, const std::string&, const StatusCode& ) override;
0078
0079
0080
0081 void beforeInitialize( INamedInterface* ) override;
0082 void afterInitialize( INamedInterface* ) override;
0083
0084 void beforeReinitialize( INamedInterface* ) override;
0085 void afterReinitialize( INamedInterface* ) override;
0086
0087 void beforeExecute( INamedInterface* ) override;
0088 void afterExecute( INamedInterface*, const StatusCode& ) override;
0089
0090 void beforeFinalize( INamedInterface* ) override;
0091 void afterFinalize( INamedInterface* ) override;
0092
0093 virtual StatusCode initialize();
0094 virtual StatusCode finalize();
0095
0096 const std::string& name() const override;
0097
0098 bool isEnabled() const override;
0099
0100
0101
0102
0103
0104 SmartIF<ISvcLocator>& serviceLocator() const override;
0105
0106
0107
0108 template <class T>
0109 StatusCode service( std::string_view name, T*& svc, bool createIf = false ) const {
0110 auto ptr = serviceLocator()->service<T>( name, createIf );
0111 if ( ptr ) {
0112 svc = ptr.get();
0113 svc->addRef();
0114 return StatusCode::SUCCESS;
0115 }
0116 svc = nullptr;
0117 return StatusCode::FAILURE;
0118 }
0119
0120 template <class T = IService>
0121 SmartIF<T> service( std::string_view name, bool createIf = false ) const {
0122 return serviceLocator()->service<T>( name, createIf );
0123 }
0124
0125 private:
0126 std::string m_name;
0127
0128 mutable SmartIF<ISvcLocator> m_pSvcLocator;
0129
0130 Gaudi::Property<int> m_outputLevel{
0131 this, "OutputLevel", MSG::NIL,
0132 [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); },
0133 "output level" };
0134 Gaudi::Property<bool> m_isEnabled{ this, "Enable", true, "should the auditor be used or not" };
0135
0136 bool m_isInitialized = false;
0137 bool m_isFinalized = false;
0138 };
0139
0140 #endif