IDNumber.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Provenance_IDNumber_h
2 #define canvas_Persistency_Provenance_IDNumber_h
3 // vim: set sw=2 expandtab :
4 
6 #include <cstdint>
7 
8 namespace art {
9 
10  template <Level>
11  struct IDNumber;
12 
13  template <>
14  struct IDNumber<Level::Event> {
15  using type = std::uint32_t;
16  static constexpr type
17  invalid() noexcept
18  {
19  return -1u;
20  }
21  static constexpr type
22  max_valid() noexcept
23  {
24  return invalid() - 1u;
25  }
26  static constexpr type
27  flush_value() noexcept
28  {
29  return max_valid();
30  }
31  static constexpr type
32  max_natural() noexcept
33  {
34  return flush_value() - 1u;
35  }
36  static constexpr type
37  first() noexcept
38  {
39  return 1u;
40  }
41  static type
42  next(type const n) noexcept
43  {
44  return n + 1u;
45  }
46  };
47 
48  template <>
49  struct IDNumber<Level::SubRun> {
50  using type = std::uint32_t;
51  static constexpr type
52  invalid() noexcept
53  {
54  return -1u;
55  }
56  static constexpr type
57  max_valid() noexcept
58  {
59  return invalid() - 1u;
60  }
61  static constexpr type
62  flush_value() noexcept
63  {
64  return max_valid();
65  }
66  static constexpr type
67  max_natural() noexcept
68  {
69  return flush_value() - 1u;
70  }
71  static constexpr type
72  first() noexcept
73  {
74  return 0u;
75  }
76  };
77 
78  template <>
79  struct IDNumber<Level::Run> {
80  using type = std::uint32_t;
81  static constexpr type
82  invalid() noexcept
83  {
84  return -1u;
85  }
86  static constexpr type
87  max_valid() noexcept
88  {
89  return invalid() - 1u;
90  }
91  static constexpr type
92  flush_value() noexcept
93  {
94  return max_valid();
95  }
96  static constexpr type
97  max_natural() noexcept
98  {
99  return flush_value() - 1u;
100  }
101  static constexpr type
102  first() noexcept
103  {
104  return 1u;
105  }
106  };
107 
108  template <Level L>
109  using IDNumber_t = typename IDNumber<L>::type;
110 
111  template <Level L = Level::Event>
112  constexpr bool
113  is_valid(IDNumber_t<L> const id) noexcept
114  {
115  return id != IDNumber<L>::invalid();
116  }
117 
121 
122 } // namespace art
123 
124 #endif /* canvas_Persistency_Provenance_IDNumber_h */
125 
126 // Local variables:
127 // mode: c++
128 // End:
static constexpr type first() noexcept
Definition: IDNumber.h:102
static constexpr type max_natural() noexcept
Definition: IDNumber.h:97
static constexpr type invalid() noexcept
Definition: IDNumber.h:17
static constexpr type first() noexcept
Definition: IDNumber.h:72
static constexpr type max_valid() noexcept
Definition: IDNumber.h:57
static constexpr type invalid() noexcept
Definition: IDNumber.h:82
Level
Definition: Level.h:13
static constexpr type max_valid() noexcept
Definition: IDNumber.h:22
Definition: Run.h:17
static constexpr type flush_value() noexcept
Definition: IDNumber.h:27
constexpr bool is_valid(IDNumber_t< L > const id) noexcept
Definition: IDNumber.h:113
static constexpr type flush_value() noexcept
Definition: IDNumber.h:92
std::void_t< T > n
typename IDNumber< L >::type IDNumber_t
Definition: IDNumber.h:109
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
static constexpr type max_natural() noexcept
Definition: IDNumber.h:67
static type next(type const n) noexcept
Definition: IDNumber.h:42
static constexpr type max_valid() noexcept
Definition: IDNumber.h:87
static constexpr type first() noexcept
Definition: IDNumber.h:37
static constexpr type max_natural() noexcept
Definition: IDNumber.h:32
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
static constexpr type invalid() noexcept
Definition: IDNumber.h:52
static constexpr type flush_value() noexcept
Definition: IDNumber.h:62
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120