OutputFileGranularity.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_OutputFileGranularity_h
2 #define art_Framework_Core_OutputFileGranularity_h
3 
5 #include <stdexcept>
6 #include <type_traits>
7 
8 namespace art {
9 
10  class Granularity {
11  public:
12  enum BT { Event, SubRun, Run, InputFile, Job, Unset };
13 
14  Granularity(BT const b) : b_{b} {}
15 
16  BT
17  operator()() const
18  {
19  return b_;
20  }
21  operator std::size_t() const { return static_cast<std::size_t>(b_); }
22 
23  static constexpr std::size_t
25  {
26  return Unset;
27  }
28 
29  static BT
30  value(std::string const& spec)
31  {
32  if (spec == "Event")
33  return Event;
34  else if (spec == "SubRun")
35  return SubRun;
36  else if (spec == "Run")
37  return Run;
38  else if (spec == "InputFile")
39  return InputFile;
40  else if (spec == "Job")
41  return Job;
42  else if (spec == "Unset")
43  return Unset;
44  else
46  << "Specified output-file switching boundary (\"" << spec
47  << "\") not supported.\n"
48  "Please choose from:\n"
49  " \"Event\"\n"
50  " \"SubRun\"\n"
51  " \"Run\"\n"
52  " \"InputFile\"\n"
53  " \"Job\"\n"
54  " \"Unset\"";
55  }
56 
57  private:
58  BT b_;
59  };
60 
61  inline std::ostream&
62  operator<<(std::ostream& os, Granularity const& b)
63  {
64  std::string token{"Unset"};
65  switch (b()) {
66  case Granularity::Event:
67  token = "Event";
68  break;
70  token = "SubRun";
71  break;
72  case Granularity::Run:
73  token = "Run";
74  break;
76  token = "InputFile";
77  break;
78  case Granularity::Job:
79  token = "Job";
80  break;
81  case Granularity::Unset:;
82  }
83  os << token;
84  return os;
85  }
86 }
87 
88 #endif /* art_Framework_Core_OutputFileGranularity_h */
89 
90 // Local variables:
91 // mode: c++
92 // End:
std::ostream & operator<<(std::ostream &os, EDAnalyzer::Table< T > const &t)
Definition: EDAnalyzer.h:184
static constexpr std::size_t NBoundaries()
static BT value(std::string const &spec)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
const hit & b
Definition: hits.cxx:21
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
::xsd::cxx::tree::token< char, normalized_string > token
Definition: Database.h:156
enum BeamMode string