Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-12 08:56:01

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIKERNEL_AUDITOR_H
0012 #define GAUDIKERNEL_AUDITOR_H
0013 
0014 // Include files
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 // Forward declarations
0026 class IService;
0027 class IMessageSvc;
0028 
0029 /** @class Auditor Auditor.h GaudiKernel/Auditor.h
0030 
0031     Base class from which all concrete auditor classes should be derived.
0032     The only base class functionality which may be used in the
0033     constructor of a concrete auditor is the declaration of
0034     member variables as properties. All other functionality,
0035     i.e. the use of services, may be used only in
0036     initialize() and afterwards.
0037 
0038     @author David Quarrie
0039     @date   2000
0040     @author Marco Clemencic
0041     @date   2008-03
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   /** Constructor
0048       @param name    The algorithm object's name
0049       @param svcloc  A pointer to a service location service */
0050   Auditor( std::string name, ISvcLocator* svcloc );
0051 
0052   Auditor( const Auditor& a )              = delete;
0053   Auditor& operator=( const Auditor& rhs ) = delete;
0054 
0055   /** Initialization method invoked by the framework. This method is responsible
0056       for any bookkeeping of initialization required by the framework itself.
0057   */
0058   StatusCode sysInitialize() override;
0059   /** Finalization method invoked by the framework. This method is responsible
0060       for any bookkeeping of initialization required by the framework itself.
0061   */
0062   StatusCode sysFinalize() override;
0063 
0064   /// The following methods are meant to be implemented by the child class...
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   // Obsolete methods
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   /** The standard service locator. Returns a pointer to the service locator service.
0100       This service may be used by an auditor to request any services it requires in
0101       addition to those provided by default.
0102   */
0103   SmartIF<ISvcLocator>& serviceLocator() const override;
0104 
0105   /** Access a service by name, creating it if it doesn't already exist.
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; ///< Auditor's name for identification
0127 
0128   mutable SmartIF<ISvcLocator> m_pSvcLocator; ///< Pointer to service locator service
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; ///< Auditor has been initialized flag
0137   bool m_isFinalized   = false; ///< Auditor has been finalized flag
0138 };
0139 
0140 #endif // GAUDIKERNEL_AUDITOR_H