seqeron 0.18.0
Loading...
Searching...
No Matches
GroupDirectory.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <string>
6#include <string_view>
7#include <vector>
8
11
13
14namespace detail {
15class GroupResolution;
16} // namespace detail
17
26{
27 public:
34 [[nodiscard]] std::uint16_t mask(const std::string_view name) const
35 {
36 for (std::size_t slot = 0; slot < m_names.size(); ++slot)
37 {
38 if (!m_names[slot].empty() && m_names[slot] == name)
39 {
40 return static_cast<std::uint16_t>(1U << slot);
41 }
42 }
43 return 0;
44 }
45
52 [[nodiscard]] std::string_view name(const std::int32_t groupId) const
53 {
54 return groupId < 1 || groupId > protocol::MAX_GROUPS ? std::string_view{} : m_names[groupId - 1];
55 }
56
57 private:
59
60 explicit GroupDirectory(const std::vector<protocol::SnapshotGroup>& groups)
61 {
62 for (const protocol::SnapshotGroup& group : groups)
63 {
64 m_names[group.groupId - 1] = group.groupName;
65 m_activeMask |= bit(group.groupId);
66 }
67 }
68
69 static std::uint16_t bit(const std::int32_t groupId)
70 {
71 return static_cast<std::uint16_t>(1U << (groupId - 1));
72 }
73
74 std::array<std::string, protocol::MAX_GROUPS> m_names;
75 std::uint16_t m_activeMask = 0;
76};
77
78} // namespace org::limitless::seqeron::app
The log's group table, as a producer addresses it (spec A-9): a group's name to its bit of groupMask,...
Definition GroupDirectory.hpp:26
std::string_view name(const std::int32_t groupId) const
A group's name, to label it.
Definition GroupDirectory.hpp:52
std::uint16_t mask(const std::string_view name) const
A group's bit.
Definition GroupDirectory.hpp:34
friend class detail::GroupResolution
Definition GroupDirectory.hpp:58
Definition ClusterError.hpp:5
constexpr std::int32_t MAX_GROUPS
Definition SequencedFrame.hpp:50