InputSource.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_InputSource_h
2 #define art_Framework_Core_InputSource_h
3 
4 //----------------------------------------------------------------------
5 //
6 // InputSource is the abstract interface implemented by all concrete
7 // sources.
8 //
9 //----------------------------------------------------------------------
10 
14 #include "cetlib/exempt_ptr.h"
15 
16 #include <memory>
17 #include <ostream>
18 
19 namespace art {
20  namespace input {
22  inline std::ostream&
23  operator<<(std::ostream& os, ItemType const it)
24  {
25  switch (it) {
26  case IsInvalid:
27  os << "Invalid";
28  break;
29  case IsStop:
30  os << "Stop";
31  break;
32  case IsFile:
33  os << "InputFile";
34  break;
35  case IsRun:
36  os << "Run";
37  break;
38  case IsSubRun:
39  os << "SubRun";
40  break;
41  case IsEvent:
42  os << "Event";
43  }
44  return os;
45  }
46  }
47 
48  class InputSource {
49  public:
50  // TODO:
51  // This enum should probably be moved outside of InputSource.
52  enum ProcessingMode { Runs, RunsAndSubRuns, RunsSubRunsAndEvents };
53 
54  explicit InputSource(ModuleDescription const& md) : moduleDescription_{md}
55  {}
56  virtual ~InputSource() noexcept = default;
57 
58  auto const&
60  {
61  return moduleDescription_;
62  }
63  auto const&
65  {
66  return moduleDescription_.processConfiguration();
67  }
68 
69  // Skip forward (or backward, if n<0) n events. Derived classes
70  // that can not perform random access should not implement this
71  // function; the default implementation will throw an exception.
72  virtual void skipEvents(int n);
73 
74  // Rewind to the beginning of input. Derived classes that can not
75  // perform this function will throw an exception.
76  virtual void rewind();
77 
78  virtual void doBeginJob();
79  virtual void doEndJob();
80 
81  virtual input::ItemType nextItemType() = 0;
82  virtual std::unique_ptr<FileBlock> readFile() = 0;
83  virtual void closeFile() = 0;
84  virtual std::unique_ptr<RunPrincipal> readRun() = 0;
85  virtual std::unique_ptr<SubRunPrincipal> readSubRun(
87  virtual std::unique_ptr<EventPrincipal> readEvent(
89  virtual std::unique_ptr<RangeSetHandler> runRangeSetHandler() = 0;
90  virtual std::unique_ptr<RangeSetHandler> subRunRangeSetHandler() = 0;
91 
92  private:
94  };
95 }
96 
97 #endif /* art_Framework_Core_InputSource_h */
98 
99 // Local Variables:
100 // mode: c++
101 // End:
set< int >::iterator it
auto const & moduleDescription() const
Definition: InputSource.h:59
std::ostream & operator<<(std::ostream &os, ItemType const it)
Definition: InputSource.h:23
InputSource(ModuleDescription const &md)
Definition: InputSource.h:54
ModuleDescription moduleDescription_
Definition: InputSource.h:93
auto const & processConfiguration() const
Definition: InputSource.h:64
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8