|
||||
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 GAUDIKERNEL_IALGCONTEXTSVC_H 0012 #define GAUDIKERNEL_IALGCONTEXTSVC_H 0013 // ============================================================================ 0014 // Include files: 0015 // ============================================================================ 0016 // STD & STL 0017 // ============================================================================ 0018 #include <vector> 0019 // ============================================================================ 0020 // GaudiKernel 0021 // ============================================================================ 0022 #include "GaudiKernel/EventContext.h" 0023 #include "GaudiKernel/IAlgorithm.h" 0024 #include "GaudiKernel/IInterface.h" 0025 #include "GaudiKernel/SmartIF.h" 0026 // ============================================================================ 0027 /** @class IAlgContextSvc 0028 * An abstract interface for Algorithm Context Service 0029 * @author ATLAS Collaboration 0030 * @author Vanya BELYAEV ibelyaev@physics.syr.edu 0031 * @date 2007-03-07 (modified) 0032 */ 0033 class GAUDI_API IAlgContextSvc : virtual public IInterface { 0034 public: 0035 /// InterfaceID 0036 DeclareInterfaceID( IAlgContextSvc, 4, 0 ); 0037 /// the actual type of algorithm' stack 0038 typedef std::vector<IAlgorithm*> Algorithms; 0039 0040 public: 0041 /// set the currently executing algorithm ("push_back") 0042 virtual StatusCode setCurrentAlg( IAlgorithm* a, const EventContext& context ) = 0; 0043 /// remove the algorithm ("pop_back") 0044 virtual StatusCode unSetCurrentAlg( IAlgorithm* a, const EventContext& context ) = 0; 0045 /// accessor to current algorithm: 0046 virtual IAlgorithm* currentAlg() const = 0; 0047 /// get the stack of executed algorithms 0048 virtual const Algorithms& algorithms() const = 0; 0049 }; 0050 // ============================================================================ 0051 namespace Gaudi { 0052 namespace Utils { 0053 /** @class AlgContext 0054 * Helper "sentry" class to automatize the safe register/unregister 0055 * the algorithm's context 0056 * 0057 * Typical explicit usage: 0058 * 0059 * @code 0060 * 0061 * StatusCode MyAlg::execute() 0062 * { 0063 * IAlgContextSvc* acs = ... ; 0064 * // define the context 0065 * Gaudi::Utils::AlgContext sentry ( this , acs ) ; 0066 * 0067 * ... 0068 * 0069 * return StatusCode::SUCCESS ; 0070 * } 0071 * 0072 * @endcode 0073 * 0074 * Note: for the regular job the context is properly 0075 * defined with the help of corresponding auditor 0076 * AlgContextAuditor. This helper class is needed only 0077 * if one needs to ensure that the algorithm must register 0078 * its context independently on job/auditor configuration 0079 * 0080 * @see AlgContextAuditor 0081 * @author Vanya BELYAEV ibelyaev@phys.syr.edu 0082 * @date 2007-03-07 0083 */ 0084 class GAUDI_API AlgContext final { 0085 public: 0086 /** constructor from the service and the algorithm 0087 * Internally invokes IAlgContextSvc::setCurrentAlg 0088 * @see IAlgorithm 0089 * @see IAlgContextSvc 0090 * @param alg pointer to the current algorithm 0091 * @param svc pointer to algorithm context service 0092 * @param context current event context 0093 */ 0094 AlgContext( IAlgorithm* alg, IAlgContextSvc* svc, const EventContext& context ); 0095 0096 /** constructor from the service and the algorithm (single thread case) 0097 * Internally invokes IAlgContextSvc::setCurrentAlg 0098 * @see IAlgorithm 0099 * @see IAlgContextSvc 0100 * @param alg pointer to the current algorithm 0101 * @param svc pointer to algorithm context service 0102 */ 0103 AlgContext( IAlgorithm* alg, IAlgContextSvc* svc ); 0104 0105 /// Prevent use of temporary EventContext as current context. 0106 /// @see [gaudi/Gaudi#73](https://gitlab.cern.ch/gaudi/Gaudi/issues/73) 0107 AlgContext( IAlgorithm* alg, IAlgContextSvc* svc, EventContext&& context ) = delete; 0108 0109 /** destructor 0110 * Internally invokes IAlgContextSvc::unSetCurrentAlg 0111 * @see IAlgorithm 0112 * @see IAlgContextSvc 0113 */ 0114 ~AlgContext(); 0115 0116 private: 0117 // copy constructor is disabled 0118 AlgContext( const AlgContext& right ) = delete; 0119 // assignement operator is disabled 0120 AlgContext& operator=( const AlgContext& right ) = delete; 0121 0122 private: 0123 SmartIF<IAlgContextSvc> m_svc; 0124 SmartIF<IAlgorithm> m_alg; 0125 const EventContext& m_context; 0126 }; 0127 } // namespace Utils 0128 } // end of namespace Gaudi 0129 0130 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |