LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
InputSource.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_InputSource_h
2 #define art_Framework_Core_InputSource_h
3 // vim: set sw=2 expandtab :
4 
5 //
6 // InputSource is the abstract interface implemented by all concrete
7 // sources.
8 //
9 
10 #include "art/Framework/Core/fwd.h"
13 #include "cetlib/exempt_ptr.h"
14 
15 #include <memory>
16 #include <ostream>
17 
18 namespace art {
19 
20  namespace input {
21 
22  enum ItemType {
23  IsInvalid, // 0
24  IsStop, // 1
25  IsFile, // 2
26  IsRun, // 3
27  IsSubRun, // 4
28  IsEvent // 5
29  };
30 
31  inline std::ostream&
32  operator<<(std::ostream& os, ItemType const it)
33  {
34  switch (it) {
35  case IsInvalid:
36  os << "Invalid";
37  break;
38  case IsStop:
39  os << "Stop";
40  break;
41  case IsFile:
42  os << "InputFile";
43  break;
44  case IsRun:
45  os << "Run";
46  break;
47  case IsSubRun:
48  os << "SubRun";
49  break;
50  case IsEvent:
51  os << "Event";
52  break;
53  }
54  return os;
55  }
56 
57  } // namespace input
58 
59  class InputSource {
60  public:
62  Runs, // 0
64  RunsSubRunsAndEvents // 2
65  };
66 
67  static ProcessingMode mode(std::string const& modeString);
68 
69  virtual ~InputSource();
70 
71  explicit InputSource(ModuleDescription const&);
72 
73  InputSource(InputSource const&) = delete;
74  InputSource(InputSource&&) = delete;
75 
76  InputSource& operator=(InputSource const&) = delete;
77  InputSource& operator=(InputSource&&) = delete;
78 
79  // Serial Access Interface
80  virtual input::ItemType nextItemType() = 0;
81  virtual std::unique_ptr<FileBlock> readFile() = 0;
82  virtual void closeFile() = 0;
83  virtual std::unique_ptr<RunPrincipal> readRun() = 0;
84  virtual std::unique_ptr<SubRunPrincipal> readSubRun(
85  cet::exempt_ptr<RunPrincipal const> rp) = 0;
86  virtual std::unique_ptr<EventPrincipal> readEvent(
87  cet::exempt_ptr<SubRunPrincipal const> srp) = 0;
88  virtual std::unique_ptr<RangeSetHandler> runRangeSetHandler() = 0;
89  virtual std::unique_ptr<RangeSetHandler> subRunRangeSetHandler() = 0;
90 
91  // Job Interface
92  virtual void doBeginJob();
93  virtual void doEndJob();
94 
95  // Random Access Interface
96 
97  // Skip forward (or backward, if n<0) n events. Derived classes
98  // that cannot perform random access should not implement this
99  // function; the default implementation will throw an exception.
100  virtual void skipEvents(int n);
101 
102  ModuleDescription const& moduleDescription() const;
103  ProcessConfiguration const& processConfiguration() const;
104 
105  private:
107  };
108 
109 } // namespace art
110 
111 #endif /* art_Framework_Core_InputSource_h */
112 
113 // Local Variables:
114 // mode: c++
115 // End:
std::ostream & operator<<(std::ostream &os, ItemType const it)
Definition: InputSource.h:32
ModuleDescription moduleDescription_
Definition: InputSource.h:106
Definition: MVAAlg.h:12
Char_t n[5]