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 
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  virtual ~InputSource() noexcept;
68 
70 
71  InputSource(InputSource const&) = delete;
72  InputSource(InputSource&&) = delete;
73 
74  InputSource& operator=(InputSource const&) = delete;
75  InputSource& operator=(InputSource&&) = delete;
76 
77  // Serial Access Interface
78  virtual input::ItemType nextItemType() = 0;
79  virtual std::unique_ptr<FileBlock> readFile() = 0;
80  virtual void closeFile() = 0;
81  virtual std::unique_ptr<RunPrincipal> readRun() = 0;
82  virtual std::unique_ptr<SubRunPrincipal> readSubRun(
83  cet::exempt_ptr<RunPrincipal const> rp) = 0;
84  virtual std::unique_ptr<EventPrincipal> readEvent(
85  cet::exempt_ptr<SubRunPrincipal const> srp) = 0;
86  virtual std::unique_ptr<RangeSetHandler> runRangeSetHandler() = 0;
87  virtual std::unique_ptr<RangeSetHandler> subRunRangeSetHandler() = 0;
88 
89  // Job Interface
90  virtual void doBeginJob();
91  virtual void doEndJob();
92 
93  // Random Access Interface
94 
95  // Skip forward (or backward, if n<0) n events. Derived classes
96  // that cannot perform random access should not implement this
97  // function; the default implementation will throw an exception.
98  virtual void skipEvents(int n);
99 
100  // Rewind to the beginning of input. Derived classes that cannot
101  // perform this function will throw an exception.
102  virtual void rewind();
103 
104  ModuleDescription const& moduleDescription() const;
105  ProcessConfiguration const& processConfiguration() const;
106 
107  private:
108  ModuleDescription moduleDescription_;
109  };
110 
111 } // namespace art
112 
113 #endif /* art_Framework_Core_InputSource_h */
114 
115 // Local Variables:
116 // mode: c++
117 // End:
std::ostream & operator<<(std::ostream &os, ItemType const it)
Definition: InputSource.h:32
STL namespace.
void readFile(string fileName, string &content)
Definition: test_suite.cc:16
static int input(void)
Definition: code.cpp:15695
std::void_t< T > n
void closeFile(HDFFileInfoPtr hdfFileInfoPtr)