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  ,
25  IsStop // 1
26  ,
27  IsFile // 2
28  ,
29  IsRun // 3
30  ,
31  IsSubRun // 4
32  ,
33  IsEvent // 5
34  };
35 
36  inline std::ostream&
37  operator<<(std::ostream& os, ItemType const it)
38  {
39  switch (it) {
40  case IsInvalid:
41  os << "Invalid";
42  break;
43  case IsStop:
44  os << "Stop";
45  break;
46  case IsFile:
47  os << "InputFile";
48  break;
49  case IsRun:
50  os << "Run";
51  break;
52  case IsSubRun:
53  os << "SubRun";
54  break;
55  case IsEvent:
56  os << "Event";
57  break;
58  }
59  return os;
60  }
61 
62  } // namespace input
63 
64  class InputSource {
65 
66  public: // TYPES
68  Runs // 0
69  ,
70  RunsAndSubRuns // 1
71  ,
72  RunsSubRunsAndEvents // 2
73  };
74 
75  public: // MEMBER FUNCTIONS -- Special Member Functions
76  virtual ~InputSource() noexcept;
77 
79 
80  InputSource(InputSource const&) = delete;
81 
82  InputSource(InputSource&&) = delete;
83 
84  InputSource& operator=(InputSource const&) = delete;
85 
86  InputSource& operator=(InputSource&&) = delete;
87 
88  public: // MEMBER FUNCTIONS -- Serial Access Interface
89  virtual input::ItemType nextItemType() = 0;
90 
91  virtual std::unique_ptr<FileBlock> readFile() = 0;
92 
93  virtual void closeFile() = 0;
94 
95  virtual std::unique_ptr<RunPrincipal> readRun() = 0;
96 
97  virtual std::unique_ptr<SubRunPrincipal> readSubRun(
98  cet::exempt_ptr<RunPrincipal const> rp) = 0;
99 
100  virtual std::unique_ptr<EventPrincipal> readEvent(
101  cet::exempt_ptr<SubRunPrincipal const> srp) = 0;
102 
103  virtual std::unique_ptr<RangeSetHandler> runRangeSetHandler() = 0;
104 
105  virtual std::unique_ptr<RangeSetHandler> subRunRangeSetHandler() = 0;
106 
107  public: // MEMBER FUNCTIONS -- Job Interface
108  virtual void doBeginJob();
109 
110  virtual void doEndJob();
111 
112  public: // MEMBER FUNCTIONS -- Random Access Interface
113  // Skip forward (or backward, if n<0) n events. Derived classes
114  // that cannot perform random access should not implement this
115  // function; the default implementation will throw an exception.
116  virtual void skipEvents(int n);
117 
118  // Rewind to the beginning of input. Derived classes that cannot
119  // perform this function will throw an exception.
120  virtual void rewind();
121 
122  public: // MEMBER FUNCTIONS
123  ModuleDescription const& moduleDescription() const;
124 
125  ProcessConfiguration const& processConfiguration() const;
126 
127  private: // MEMBER DATA
128  ModuleDescription moduleDescription_;
129  };
130 
131 } // namespace art
132 
133 #endif /* art_Framework_Core_InputSource_h */
134 
135 // Local Variables:
136 // mode: c++
137 // End:
set< int >::iterator it
std::ostream & operator<<(std::ostream &os, ItemType const it)
Definition: InputSource.h:37
std::void_t< T > n
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8