lintel 0.2.0
Loading...
Searching...
No Matches
MessageQueues.h
Go to the documentation of this file.
1#ifndef LINTEL_MESSAGEQUEUES_H
2#define LINTEL_MESSAGEQUEUES_H
3
4#include <magic_enum/magic_enum.hpp>
5#include <map>
6#include <set>
7#include <string_view>
8
9namespace lintel {
14{
15public:
17 enum Value {
18 UNDEFINED = -1,
19 HISTORY = 0
20 };
21
23 MessageQueues() = default;
24
26 constexpr MessageQueues(Value value) : m_value(value) {}
27
32 constexpr explicit MessageQueues(std::string_view enumName)
34 {}
35
37 operator Value() const { return m_value; }
38
39 explicit operator bool() = delete;
40
42 static std::set<Value> values()
43 {
44 auto values = magic_enum::enum_values<Value>();
45 return std::set<Value>(values.begin(), values.end());
46 }
47
49 std::string toString() const { return std::string(magic_enum::enum_name<>(m_value)); }
50
55 std::string getMessageQueueName() const
56 {
57 if (m_value == Value::UNDEFINED) { throw std::runtime_error("Message Queue undefined => no name available"); }
58 return m_valueToQueueName.at(m_value);
59 }
60
61 friend std::ostream &operator<<(std::ostream &os, const MessageQueues &connectionType)
62 {
64 return os;
65 }
66
67private:
68 inline static std::map<Value, std::string> m_valueToQueueName = { { Value::HISTORY, "history" } };
69 Value m_value;
70};
71
72}// namespace lintel
73#endif// LINTEL_MESSAGEQUEUES_H
Definition MessageQueues.h:14
std::string toString() const
Definition MessageQueues.h:49
constexpr MessageQueues(std::string_view enumName)
Definition MessageQueues.h:32
Value
Definition MessageQueues.h:17
@ HISTORY
Definition MessageQueues.h:19
@ UNDEFINED
Definition MessageQueues.h:18
friend std::ostream & operator<<(std::ostream &os, const MessageQueues &connectionType)
Definition MessageQueues.h:61
std::string getMessageQueueName() const
Definition MessageQueues.h:55
constexpr MessageQueues(Value value)
Definition MessageQueues.h:26
static std::set< Value > values()
Definition MessageQueues.h:42
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9