File indexing completed on 2024-04-06 12:12:28
0001 #ifndef FWCore_Framework_MockEventProcessor_h
0002 #define FWCore_Framework_MockEventProcessor_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
0034 #include "FWCore/Framework/interface/InputSource.h"
0035
0036 #include <exception>
0037 #include <ostream>
0038 #include <memory>
0039 #include <sstream>
0040 #include <string>
0041
0042 namespace edm {
0043
0044 class MockEventProcessor {
0045 public:
0046 class TestException : public std::exception {
0047 public:
0048 TestException() noexcept : std::exception() {}
0049 };
0050
0051 MockEventProcessor(std::string const& mockData, std::ostream& output, bool iDoNotMerge);
0052
0053 void runToCompletion();
0054
0055 InputSource::ItemType nextTransitionType();
0056 InputSource::ItemType lastTransitionType() const;
0057
0058 void readFile();
0059 bool fileBlockValid() { return true; }
0060 void closeInputFile(bool cleaningUpAfterException);
0061 void openOutputFiles();
0062 void closeOutputFiles();
0063
0064 void respondToOpenInputFile();
0065 void respondToCloseInputFile();
0066
0067 void startingNewLoop();
0068 bool endOfLoop();
0069 void rewindInput();
0070 void prepareForNextLoop();
0071 bool shouldWeCloseOutput() const;
0072
0073 void doErrorStuff();
0074
0075 void beginProcessBlock(bool& beginProcessBlockSucceeded);
0076 void inputProcessBlocks();
0077 void endProcessBlock(bool cleaningUpAfterException, bool beginProcessBlockSucceeded);
0078
0079 InputSource::ItemType processRuns();
0080 void processRun();
0081 InputSource::ItemType processLumis();
0082
0083 void beginRun(RunNumber_t run);
0084
0085 void endUnfinishedRun(bool);
0086
0087 void endRun();
0088
0089 void endUnfinishedLumi(bool);
0090
0091 void readRun();
0092 void readAndMergeRun();
0093 LuminosityBlockNumber_t readLuminosityBlock();
0094 LuminosityBlockNumber_t readAndMergeLumi();
0095 void writeRun();
0096 void clearRunPrincipal();
0097 void writeLumi();
0098 void clearLumiPrincipal();
0099
0100 bool shouldWeStop() const;
0101
0102 void setExceptionMessageFiles(std::string& message);
0103 void setExceptionMessageRuns();
0104 void setExceptionMessageLumis();
0105
0106 bool setDeferredException(std::exception_ptr);
0107
0108 private:
0109 InputSource::ItemType readAndProcessEvents();
0110 void readAndProcessEvent();
0111 void throwIfNeeded();
0112 void endLumi();
0113
0114 std::string mockData_;
0115 std::ostream& output_;
0116 std::istringstream input_;
0117
0118 bool lumiStatus_ = false;
0119 LuminosityBlockNumber_t currentLumiNumber_ = 0;
0120 bool didGlobalBeginLumiSucceed_ = false;
0121 InputSource::ItemType lastTransition_ = InputSource::ItemType::IsInvalid;
0122
0123 bool currentRun_ = false;
0124 RunNumber_t currentRunNumber_ = 0;
0125 bool didGlobalBeginRunSucceed_ = false;
0126
0127 RunNumber_t nextRun_;
0128 LuminosityBlockNumber_t nextLumi_;
0129
0130 bool doNotMerge_;
0131 bool shouldWeCloseOutput_;
0132 bool shouldWeEndLoop_;
0133 bool shouldWeStop_;
0134 bool eventProcessed_;
0135 bool reachedEndOfInput_;
0136 bool shouldThrow_;
0137 };
0138 }
0139
0140 #endif