ExecutionCounts.h
Go to the documentation of this file.
1 #ifndef art_Framework_Principal_ExecutionCounts_h
2 #define art_Framework_Principal_ExecutionCounts_h
3 
4 #include <array>
5 
6 namespace art {
7 
8  // ==============================================
9  // Counting-statistics fields
10 
11  namespace stats {
12  struct Visited {
13  std::size_t value{};
14  };
15  struct Run {
16  std::size_t value{};
17  };
18  struct Passed {
19  std::size_t value{};
20  };
21  struct Failed {
22  std::size_t value{};
23  };
24  struct ExceptionThrown {
25  std::size_t value{};
26  };
27  }
28 
29  // ==============================================
30  template <typename... ARGS>
32  public:
33  template <typename FIELD>
34  std::size_t times() const;
35 
36  template <typename HEAD_FIELD>
37  void increment();
38 
39  template <typename HEAD_FIELD, typename... TAIL_FIELDS>
40  std::enable_if_t<(sizeof...(TAIL_FIELDS) > 0)> increment();
41 
42  void update(bool const rc);
43  void reset();
44 
45  private:
46  std::tuple<ARGS...> counts_; // Value-initialized
47  };
48 
49  // ================================================
50  // Type aliases
51 
53  stats::Run,
57 
58  // ==============================================
59  // IMPLEMENTATION for ExecutionCounts
60 
61  template <typename... ARGS>
62  template <typename FIELD>
63  std::size_t
65  {
66  return std::get<FIELD>(counts_).value;
67  }
68 
69  template <typename... ARGS>
70  template <typename FIELD>
71  void
73  {
74  ++std::get<FIELD>(counts_).value;
75  }
76 
77  template <typename... ARGS>
78  template <typename HEAD_FIELD, typename... TAIL_FIELDS>
79  std::enable_if_t<(sizeof...(TAIL_FIELDS) > 0)>
81  {
82  increment<HEAD_FIELD>();
83  increment<TAIL_FIELDS...>();
84  }
85 
86  template <typename... ARGS>
87  void
89  {
90  if (rc) {
91  increment<stats::Passed>();
92  } else {
93  increment<stats::Failed>();
94  }
95  }
96 
97  template <typename... ARGS>
98  void
100  {
101  counts_ = std::tuple<ARGS...>();
102  }
103 }
104 
105 #endif /* art_Framework_Principal_ExecutionCounts_h */
106 
107 // Local variables:
108 // mode: c++
109 // End:
std::size_t times() const
int stats(TString inputFilePath, Int_t firstRun, Int_t lastRun, Float_t thresh, TString myDet)
Definition: stats.C:13
const XML_Char int const XML_Char * value
Definition: expat.h:331
std::tuple< ARGS... > counts_
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
void update(bool const rc)