Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:38

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 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 GAUDI_IAUDITOR_H
0012 #define GAUDI_IAUDITOR_H
0013 
0014 // Include files
0015 #include "GaudiKernel/INamedInterface.h"
0016 #include <array>
0017 #include <string>
0018 
0019 /** @class IAuditor IAuditor.h GaudiKernel/IAuditor.h
0020 
0021     The IAuditor is the interface implmented by the AlgAuditor base class.
0022     Concrete auditors, derived from the AlgAuditor base class are controlled
0023     via this interface.
0024 
0025     @author Marjorie Shapiro, LBNL
0026     @author Marco Clemencic <marco.clemencic@cern.ch>
0027 */
0028 class GAUDI_API IAuditor : virtual public INamedInterface {
0029 public:
0030   /// InterfaceID
0031   DeclareInterfaceID( IAuditor, 3, 0 );
0032 
0033   /// Defines the standard (= used by the framework) auditable event types.
0034   enum StandardEventType { Initialize, ReInitialize, Execute, Finalize, Start, Stop, ReStart };
0035 
0036   /// Type used to allow users to specify a custom event to be audit.
0037   /// Examples of custom events are callbacks (see
0038   /// <a href="https://savannah.cern.ch/patch/index.php?1725">patch #1725</a>).
0039   typedef std::string CustomEventType;
0040   /// Used in function calls for optimization purposes.
0041   typedef const CustomEventType& CustomEventTypeRef;
0042 
0043   /// Audit the start of a standard "event".
0044   virtual void before( StandardEventType, INamedInterface* ) = 0;
0045   /// Audit the start of a standard "event" for callers that do not implement INamedInterface.
0046   virtual void before( StandardEventType, const std::string& ) = 0;
0047 
0048   /// Audit the start of a custom "event".
0049   virtual void before( CustomEventTypeRef, INamedInterface* ) = 0;
0050   /// Audit the start of a custom "event" for callers that do not implement INamedInterface.
0051   virtual void before( CustomEventTypeRef, const std::string& ) = 0;
0052 
0053   /// Audit the end of a standard "event".
0054   virtual void after( StandardEventType, INamedInterface*, const StatusCode& sc = StatusCode::SUCCESS ) = 0;
0055   /// Audit the end of a standard "event" for callers that do not implement INamedInterface.
0056   virtual void after( StandardEventType, const std::string&, const StatusCode& sc = StatusCode::SUCCESS ) = 0;
0057 
0058   /// Audit the end of a custom "event".
0059   virtual void after( CustomEventTypeRef, INamedInterface*, const StatusCode& sc = StatusCode::SUCCESS ) = 0;
0060   /// Audit the end of a custom "event" for callers that do not implement INamedInterface.
0061   virtual void after( CustomEventTypeRef, const std::string&, const StatusCode& sc = StatusCode::SUCCESS ) = 0;
0062 
0063   /// Tell if the auditor is enabled or not.
0064   virtual bool isEnabled() const = 0;
0065 
0066   // ------- Obsolete interface ------
0067   /// \deprecated use before
0068   virtual void beforeInitialize( INamedInterface* ) = 0;
0069   /// \deprecated use after
0070   virtual void afterInitialize( INamedInterface* ) = 0;
0071 
0072   /// \deprecated use before
0073   virtual void beforeReinitialize( INamedInterface* ) = 0;
0074   /// \deprecated use after
0075   virtual void afterReinitialize( INamedInterface* ) = 0;
0076 
0077   /// \deprecated use before
0078   virtual void beforeExecute( INamedInterface* ) = 0;
0079   /// \deprecated use after
0080   virtual void afterExecute( INamedInterface*, const StatusCode& ) = 0;
0081 
0082   /// \deprecated use before
0083   virtual void beforeFinalize( INamedInterface* ) = 0;
0084   /// \deprecated use after
0085   virtual void afterFinalize( INamedInterface* ) = 0;
0086 
0087   /// Used by AuditorSvc.
0088   virtual StatusCode sysInitialize() = 0;
0089 
0090   /// Used by AuditorSvc.
0091   virtual StatusCode sysFinalize() = 0;
0092 };
0093 
0094 /// Simple mapping function from IAuditor::StandardEventType to string.
0095 inline const char* toStr( IAuditor::StandardEventType e ) {
0096   static const std::array<const char*, IAuditor::StandardEventType::ReStart + 1> s_tbl = {
0097       { "Initialize", "ReInitialize", "Execute", "Finalize", "Start", "Stop", "ReStart" } };
0098   return e <= IAuditor::StandardEventType::ReStart ? s_tbl[e] : nullptr;
0099 }
0100 
0101 inline std::ostream& operator<<( std::ostream& s, IAuditor::StandardEventType e ) { return s << toStr( e ); }
0102 
0103 #endif // GAUDIKERNEL_IAUDITOR_H