File indexing completed on 2025-09-12 08:56:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIKERNEL_AUDITOR_H
0012 #define GAUDIKERNEL_AUDITOR_H
0013
0014
0015 #include <Gaudi/PluginService.h>
0016 #include <Gaudi/PropertyFwd.h>
0017 #include <GaudiKernel/CommonMessaging.h>
0018 #include <GaudiKernel/IAuditor.h>
0019 #include <GaudiKernel/IProperty.h>
0020 #include <GaudiKernel/IService.h>
0021 #include <GaudiKernel/ISvcLocator.h> /*used by service(..)*/
0022 #include <GaudiKernel/PropertyHolder.h>
0023 #include <string>
0024
0025
0026 class IService;
0027 class IMessageSvc;
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 class GAUDI_API Auditor : public PropertyHolder<CommonMessaging<implements<IAuditor, IProperty>>> {
0044 public:
0045 using Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>;
0046
0047
0048
0049
0050 Auditor( std::string name, ISvcLocator* svcloc );
0051
0052 Auditor( const Auditor& a ) = delete;
0053 Auditor& operator=( const Auditor& rhs ) = delete;
0054
0055
0056
0057
0058 StatusCode sysInitialize() override;
0059
0060
0061
0062 StatusCode sysFinalize() override;
0063
0064
0065
0066 void before( StandardEventType, INamedInterface* ) override;
0067 void before( StandardEventType, const std::string& ) override;
0068
0069 void before( CustomEventTypeRef, INamedInterface* ) override;
0070 void before( CustomEventTypeRef, const std::string& ) override;
0071
0072 void after( StandardEventType, INamedInterface*, const StatusCode& ) override;
0073 void after( StandardEventType, const std::string&, const StatusCode& ) override;
0074
0075 void after( CustomEventTypeRef, INamedInterface*, const StatusCode& ) override;
0076 void after( CustomEventTypeRef, const std::string&, const StatusCode& ) override;
0077
0078
0079
0080 void beforeInitialize( INamedInterface* ) override;
0081 void afterInitialize( INamedInterface* ) override;
0082
0083 void beforeReinitialize( INamedInterface* ) override;
0084 void afterReinitialize( INamedInterface* ) override;
0085
0086 void beforeExecute( INamedInterface* ) override;
0087 void afterExecute( INamedInterface*, const StatusCode& ) override;
0088
0089 void beforeFinalize( INamedInterface* ) override;
0090 void afterFinalize( INamedInterface* ) override;
0091
0092 virtual StatusCode initialize();
0093 virtual StatusCode finalize();
0094
0095 const std::string& name() const override;
0096
0097 bool isEnabled() const override;
0098
0099
0100
0101
0102
0103 SmartIF<ISvcLocator>& serviceLocator() const override;
0104
0105
0106
0107 template <class T>
0108 [[deprecated( "use service<T>(name, createIf) -> SmartIF<T>" )]] StatusCode service( std::string_view name, T*& svc,
0109 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