ToyRawInput_source.cc
Go to the documentation of this file.
1 // ------------------------------------------------------------
2 //
3 // ToyRawInput is a RawInputSource that pretends to reconstitute several
4 // products. It exercises the Source template.
5 //
6 // ------------------------------------------------------------
7 
13 
14 namespace arttest {
15  // ToyFile is the sort of class that experimenters who make use of
16  // Source must write.
17  class ToyReader;
18 } // namespace arttest
19 
20 namespace art {
21  // We don't want the file services: we must say so by specializing the
22  // template *before* specifying the typedef.
23  template <>
24  struct Source_wantFileServices<arttest::ToyReader> {
25  static constexpr bool value = false;
26  };
27 } // namespace art
28 
29 namespace arttest {
30  // ToyRawInput is an instantiation of the Source template.
32 } // namespace arttest
33 
34 class arttest::ToyReader final : public ToySource {
35 public:
38  art::SourceHelper const& sHelper);
39 
40  void readFile(std::string const& name, art::FileBlock*& fb) override;
41 };
42 
45  art::SourceHelper const& sHelper)
46  : ToySource(ps, help, sHelper)
47 {}
48 
49 void
51 {
53  throw_exception_from("readFile");
54  if (!data_.get_if_present(name, fileData_)) {
56  << "ToyReader expects to find a parameter representing a file's\n"
57  << "contents whose name is " << name << "\n";
58  }
60  current_ = fileData_.begin();
61  end_ = fileData_.end();
62  fb = new art::FileBlock(art::FileFormatVersion(1, "ToyReader 2011a"),
64 }
65 
ToyReader(fhicl::ParameterSet const &ps, art::ProductRegistryHelper &help, art::SourceHelper const &sHelper)
std::string currentFilename_
Definition: ToySource.h:53
static const double ps
Definition: Units.h:103
std::string string
Definition: nybbler.cc:12
static void throw_exception_from(const char *funcname)
Definition: ToySource.cc:121
art::Source< ToyReader > ToyRawInput
void readFile(string fileName, string &content)
Definition: test_suite.cc:18
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
void readFile(std::string const &name, art::FileBlock *&fb) override
bool const throw_on_readFile_
Definition: ToySource.h:57
fhicl::ParameterSet data_
Definition: ToySource.h:49
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
#define DEFINE_ART_INPUT_SOURCE(klass)