LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 
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  // Return the Event specified by the given EventID, or the next
70  // one in the input sequence after the given EventID if one with
71  // the given id can not be found. Derived classes that can not
72  // perform random access should not implement this function; the
73  // default implementation will throw an exception.
74  virtual std::unique_ptr<EventPrincipal> readEvent(EventID const& id);
75 
76  // Skip forward (or backward, if n<0) n events. Derived classes
77  // that can not perform random access should not implement this
78  // function; the default implementation will throw an exception.
79  virtual void skipEvents(int n);
80 
81  // Rewind to the beginning of input. Derived classes that can not
82  // perform this function will throw an exception.
83  virtual void rewind();
84 
85  virtual void doBeginJob();
86  virtual void doEndJob();
87 
88  virtual input::ItemType nextItemType() = 0;
89  virtual std::unique_ptr<FileBlock> readFile() = 0;
90  virtual void closeFile() = 0;
91  virtual std::unique_ptr<RunPrincipal> readRun() = 0;
92  virtual std::unique_ptr<SubRunPrincipal> readSubRun(
93  cet::exempt_ptr<RunPrincipal const> rp) = 0;
94  virtual std::unique_ptr<EventPrincipal> readEvent(
95  cet::exempt_ptr<SubRunPrincipal const> srp) = 0;
96  virtual std::unique_ptr<RangeSetHandler> runRangeSetHandler() = 0;
97  virtual std::unique_ptr<RangeSetHandler> subRunRangeSetHandler() = 0;
98 
99  private:
101  };
102 }
103 
104 #endif /* art_Framework_Core_InputSource_h */
105 
106 // Local Variables:
107 // mode: c++
108 // End:
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:100
auto const & processConfiguration() const
Definition: InputSource.h:64
HLT enums.
Char_t n[5]