]>
Commit | Line | Data |
---|---|---|
224ce89b WB |
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 <ostream> | |
7 | #include <string> | |
8 | ||
9 | #include "include/encoding.h" | |
10 | ||
11 | // health_status_t | |
12 | enum health_status_t { | |
13 | HEALTH_ERR = 0, | |
14 | HEALTH_WARN = 1, | |
15 | HEALTH_OK = 2, | |
16 | }; | |
17 | ||
18 | static inline void encode(health_status_t hs, bufferlist& bl) { | |
19 | uint8_t v = hs; | |
20 | ::encode(v, bl); | |
21 | } | |
22 | static inline void decode(health_status_t& hs, bufferlist::iterator& p) { | |
23 | uint8_t v; | |
24 | ::decode(v, p); | |
25 | hs = health_status_t(v); | |
26 | } | |
27 | template<> | |
28 | struct denc_traits<health_status_t> { | |
29 | static constexpr bool supported = true; | |
30 | static constexpr bool featured = false; | |
31 | static constexpr bool bounded = true; | |
32 | static constexpr bool need_contiguous = false; | |
33 | static void bound_encode(const bufferptr& v, size_t& p, uint64_t f=0) { | |
34 | p++; | |
35 | } | |
36 | static void encode(const health_status_t& v, | |
37 | buffer::list::contiguous_appender& p, | |
38 | uint64_t f=0) { | |
39 | ::denc((uint8_t)v, p); | |
40 | } | |
41 | static void decode(health_status_t& v, buffer::ptr::iterator& p, | |
42 | uint64_t f=0) { | |
43 | uint8_t tmp; | |
44 | ::denc(tmp, p); | |
45 | v = health_status_t(tmp); | |
46 | } | |
47 | static void decode(health_status_t& v, buffer::list::iterator& p, | |
48 | uint64_t f=0) { | |
49 | uint8_t tmp; | |
50 | ::denc(tmp, p); | |
51 | v = health_status_t(tmp); | |
52 | } | |
53 | }; | |
54 | ||
55 | inline std::ostream& operator<<(std::ostream &oss, const health_status_t status) { | |
56 | switch (status) { | |
57 | case HEALTH_ERR: | |
58 | oss << "HEALTH_ERR"; | |
59 | break; | |
60 | case HEALTH_WARN: | |
61 | oss << "HEALTH_WARN"; | |
62 | break; | |
63 | case HEALTH_OK: | |
64 | oss << "HEALTH_OK"; | |
65 | break; | |
66 | } | |
67 | return oss; | |
68 | } |