Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_ServiceRegistry_StreamContext_h
0002 #define FWCore_ServiceRegistry_StreamContext_h
0003 
0004 /**\class edm::StreamContext
0005 
0006  Description: Holds pointer to ProcessContext, StreamID,
0007  transition, EventID and timestamp.
0008  This is intended primarily to be passed to Services
0009  as an argument to their callback functions.
0010 
0011  Usage:
0012 
0013 
0014 */
0015 //
0016 // Original Author: W. David Dagenhart
0017 //         Created: 7/8/2013
0018 
0019 #include "DataFormats/Provenance/interface/EventID.h"
0020 #include "DataFormats/Provenance/interface/Timestamp.h"
0021 #include "FWCore/Utilities/interface/LuminosityBlockIndex.h"
0022 #include "FWCore/Utilities/interface/RunIndex.h"
0023 #include "FWCore/Utilities/interface/StreamID.h"
0024 
0025 #include <iosfwd>
0026 #include <string_view>
0027 
0028 namespace edm {
0029 
0030   class ProcessContext;
0031 
0032   class StreamContext {
0033   public:
0034     enum class Transition {
0035       kBeginStream,
0036       kBeginRun,
0037       kBeginLuminosityBlock,
0038       kEvent,
0039       kEndLuminosityBlock,
0040       kEndRun,
0041       kEndStream,
0042       kInvalid
0043     };
0044 
0045     StreamContext(StreamID const& streamID, ProcessContext const* processContext);
0046 
0047     StreamContext(StreamID const& streamID,
0048                   Transition transition,
0049                   EventID const& eventID,
0050                   RunIndex const& runIndex,
0051                   LuminosityBlockIndex const& luminosityBlockIndex,
0052                   Timestamp const& timestamp,
0053                   ProcessContext const* processContext);
0054 
0055     StreamID const& streamID() const { return streamID_; }
0056     Transition transition() const { return transition_; }
0057     bool isAtEndTransition() const {
0058       return transition() == Transition::kEndLuminosityBlock or transition() == Transition::kEndRun;
0059     }
0060     EventID const& eventID() const { return eventID_; }  // event#==0 is a lumi, event#==0&lumi#==0 is a run
0061     RunIndex const& runIndex() const { return runIndex_; }
0062     LuminosityBlockIndex const& luminosityBlockIndex() const { return luminosityBlockIndex_; }
0063     Timestamp const& timestamp() const { return timestamp_; }
0064     ProcessContext const* processContext() const { return processContext_; }
0065 
0066     void setTransition(Transition v) { transition_ = v; }
0067     void setEventID(EventID const& v) { eventID_ = v; }
0068     void setRunIndex(RunIndex const& v) { runIndex_ = v; }
0069     void setLuminosityBlockIndex(LuminosityBlockIndex const& v) { luminosityBlockIndex_ = v; }
0070     void setTimestamp(Timestamp const& v) { timestamp_ = v; }
0071 
0072   private:
0073     StreamID streamID_;
0074     Transition transition_;
0075     EventID eventID_;  // event#==0 is a lumi, event#==0&lumi#==0 is a run
0076     RunIndex runIndex_;
0077     LuminosityBlockIndex luminosityBlockIndex_;
0078     Timestamp timestamp_;
0079     ProcessContext const* processContext_;
0080   };
0081 
0082   void exceptionContext(std::ostream&, StreamContext const&);
0083   std::ostream& operator<<(std::ostream&, StreamContext const&);
0084 
0085   std::string_view transitionName(StreamContext::Transition);
0086 }  // namespace edm
0087 #endif