Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-14 22:55:55

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 edm {
0027 
0028   class ProcessContext;
0029 
0030   class GlobalContext {
0031   public:
0032     enum class Transition {
0033       kBeginJob,
0034       kBeginProcessBlock,
0035       kAccessInputProcessBlock,
0036       kBeginRun,
0037       kBeginLuminosityBlock,
0038       kEndLuminosityBlock,
0039       kEndRun,
0040       kEndProcessBlock,
0041       kEndJob,
0042       kWriteProcessBlock,
0043       kWriteRun,
0044       kWriteLuminosityBlock
0045     };
0046 
0047     GlobalContext(Transition transition,
0048                   LuminosityBlockID const& luminosityBlockID,
0049                   RunIndex const& runIndex,
0050                   LuminosityBlockIndex const& luminosityBlockIndex,
0051                   Timestamp const& timestamp,
0052                   ProcessContext const* processContext);
0053     GlobalContext(Transition transition, ProcessContext const* processContext);
0054 
0055     Transition transition() const { return transition_; }
0056     bool isAtEndTransition() const {
0057       return transition() == Transition::kEndLuminosityBlock or transition() == Transition::kEndRun or
0058              transition() == Transition::kEndProcessBlock or transition() == Transition::kWriteRun or
0059              transition() == Transition::kWriteLuminosityBlock or transition() == Transition::kWriteProcessBlock;
0060     }
0061 
0062     LuminosityBlockID const& luminosityBlockID() const { return luminosityBlockID_; }
0063     RunIndex const& runIndex() const { return runIndex_; }
0064     LuminosityBlockIndex const& luminosityBlockIndex() const { return luminosityBlockIndex_; }
0065     Timestamp const& timestamp() const { return timestamp_; }
0066     ProcessContext const* processContext() const { return processContext_; }
0067 
0068   private:
0069     Transition transition_;
0070     LuminosityBlockID luminosityBlockID_;
0071     RunIndex runIndex_;
0072     LuminosityBlockIndex luminosityBlockIndex_;
0073     Timestamp timestamp_;
0074     ProcessContext const* processContext_;
0075   };
0076 
0077   void exceptionContext(std::ostream&, GlobalContext const&);
0078   std::ostream& operator<<(std::ostream&, GlobalContext const&);
0079 
0080   std::string_view transitionName(GlobalContext::Transition);
0081 }  // namespace edm
0082 #endif