]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #pragma once | |
5 | ||
6 | #include <cstdint> | |
7 | #include <iosfwd> | |
8 | #include <string_view> | |
9 | ||
10 | #include "common/ceph_strings.h" | |
11 | ||
12 | // the C++ version of CEPH_RELEASE_* defined by include/rados.h | |
13 | enum class ceph_release_t : std::uint8_t { | |
14 | unknown = 0, | |
15 | argonaut, | |
16 | bobtail, | |
17 | cuttlefish, | |
18 | dumpling, | |
19 | emperor, | |
20 | firefly, | |
21 | giant, | |
22 | hammer, | |
23 | infernalis, | |
24 | jewel, | |
25 | kraken, | |
26 | luminous, | |
27 | mimic, | |
28 | nautilus, | |
29 | octopus, | |
f67539c2 | 30 | pacific, |
20effc67 | 31 | quincy, |
9f95a23c TL |
32 | max, |
33 | }; | |
34 | ||
35 | std::ostream& operator<<(std::ostream& os, const ceph_release_t r); | |
36 | ||
f67539c2 | 37 | inline bool operator!(ceph_release_t& r) { |
9f95a23c TL |
38 | return (r < ceph_release_t::unknown || |
39 | r == ceph_release_t::unknown); | |
40 | } | |
41 | ||
f67539c2 | 42 | inline ceph_release_t& operator--(ceph_release_t& r) { |
9f95a23c TL |
43 | r = static_cast<ceph_release_t>(static_cast<uint8_t>(r) - 1); |
44 | return r; | |
45 | } | |
46 | ||
f67539c2 | 47 | inline ceph_release_t& operator++(ceph_release_t& r) { |
9f95a23c TL |
48 | r = static_cast<ceph_release_t>(static_cast<uint8_t>(r) + 1); |
49 | return r; | |
50 | } | |
51 | ||
f67539c2 | 52 | inline bool operator<(ceph_release_t lhs, ceph_release_t rhs) { |
9f95a23c TL |
53 | // we used to use -1 for invalid release |
54 | if (static_cast<int8_t>(lhs) < 0) { | |
55 | return true; | |
56 | } else if (static_cast<int8_t>(rhs) < 0) { | |
57 | return false; | |
58 | } | |
59 | return static_cast<uint8_t>(lhs) < static_cast<uint8_t>(rhs); | |
60 | } | |
61 | ||
f67539c2 | 62 | inline bool operator>(ceph_release_t lhs, ceph_release_t rhs) { |
9f95a23c TL |
63 | // we used to use -1 for invalid release |
64 | if (static_cast<int8_t>(lhs) < 0) { | |
65 | return false; | |
66 | } else if (static_cast<int8_t>(rhs) < 0) { | |
67 | return true; | |
68 | } | |
69 | return static_cast<uint8_t>(lhs) > static_cast<uint8_t>(rhs); | |
70 | } | |
71 | ||
f67539c2 | 72 | inline bool operator>=(ceph_release_t lhs, ceph_release_t rhs) { |
9f95a23c TL |
73 | return !(lhs < rhs); |
74 | } | |
75 | ||
76 | bool can_upgrade_from(ceph_release_t from_release, | |
77 | std::string_view from_release_name, | |
78 | std::ostream& err); | |
79 | ||
80 | ceph_release_t ceph_release_from_name(std::string_view sv); | |
81 | ceph_release_t ceph_release(); | |
82 | ||
f67539c2 TL |
83 | inline std::string_view to_string(ceph_release_t r) { |
84 | return ceph_release_name(static_cast<int>(r)); | |
85 | } | |
86 | template<typename IntType> IntType to_integer(ceph_release_t r) { | |
87 | return static_cast<IntType>(r); | |
9f95a23c | 88 | } |