Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-28 22:48:28

0001 #ifndef FWCore_ServiceRegistry_GlobalContext_h
0002 #define FWCore_ServiceRegistry_GlobalContext_h
0003 
0004 /**\class edm::GlobalContext
0005 
0006  Description: This is intended primarily to be passed to
0007 Services as an argument to their callback functions. It contains
0008 information about the current state of global processing.
0009 
0010  Usage:
0011 
0012 
0013 */
0014 //
0015 // Original Author: W. David Dagenhart
0016 //         Created: 7/10/2013
0017 
0018 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
0019 #include "DataFormats/Provenance/interface/Timestamp.h"
0020 #include "FWCore/Utilities/interface/LuminosityBlockIndex.h"
0021 #include "FWCore/Utilities/interface/RunIndex.h"
0022 
0023 #include <iosfwd>
0024 #include <string_view>
0025 
0026 namespace cms {
0027   class Exception;
0028 }
0029 
0030 namespace edm {
0031 
0032   class ProcessContext;
0033 
0034   class GlobalContext {
0035   public:
0036     enum class Transition {
0037       kBeginJob,
0038       kBeginProcessBlock,
0039       kAccessInputProcessBlock,
0040       kBeginRun,
0041       kBeginLuminosityBlock,
0042       kEndLuminosityBlock,
0043       kEndRun,
0044       kEndProcessBlock,
0045       kEndJob,
0046       kWriteProcessBlock,
0047       kWriteRun,
0048       kWriteLuminosityBlock
0049     };
0050 
0051     GlobalContext(Transition transition,
0052                   LuminosityBlockID const& luminosityBlockID,
0053                   RunIndex const& runIndex,
0054                   LuminosityBlockIndex const& luminosityBlockIndex,
0055                   Timestamp const& timestamp,
0056                   ProcessContext const* processContext);
0057     GlobalContext(Transition transition, ProcessContext const* processContext);
0058 
0059     Transition transition() const { return transition_; }
0060     bool isAtEndTransition() const {
0061       return transition() == Transition::kEndLuminosityBlock or transition() == Transition::kEndRun or
0062              transition() == Transition::kEndProcessBlock or transition() == Transition::kWriteRun or
0063              transition() == Transition::kWriteLuminosityBlock or transition() == Transition::kWriteProcessBlock;
0064     }
0065 
0066     LuminosityBlockID const& luminosityBlockID() const { return luminosityBlockID_; }
0067     RunIndex const& runIndex() const { return runIndex_; }
0068     LuminosityBlockIndex const& luminosityBlockIndex() const { return luminosityBlockIndex_; }
0069     Timestamp const& timestamp() const { return timestamp_; }
0070     ProcessContext const* processContext() const { return processContext_; }
0071 
0072   private:
0073     Transition transition_;
0074     LuminosityBlockID luminosityBlockID_;
0075     RunIndex runIndex_;
0076     LuminosityBlockIndex luminosityBlockIndex_;
0077     Timestamp timestamp_;
0078     ProcessContext const* processContext_;
0079   };
0080 
0081   void exceptionContext(std::ostream&, GlobalContext const&);
0082   std::ostream& operator<<(std::ostream&, GlobalContext const&);
0083   void exceptionContext(cms::Exception&, GlobalContext const&, char const* context);
0084 
0085   std::string_view transitionName(GlobalContext::Transition);
0086 }  // namespace edm
0087 #endif