-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4adc2c3
commit 5bf97fa
Showing
9 changed files
with
393 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include <cinttypes> | ||
#include <limits> | ||
|
||
#include "nigiri/types.h" | ||
|
||
namespace nigiri::routing { | ||
|
||
using clasz_mask_t = std::uint16_t; | ||
|
||
constexpr inline clasz_mask_t all_clasz_allowed() { | ||
return std::numeric_limits<clasz_mask_t>::max(); | ||
} | ||
|
||
constexpr inline clasz_mask_t to_mask(clasz const c) { | ||
auto const c_as_int = static_cast<std::underlying_type_t<clasz>>(c); | ||
return (1U << c_as_int); | ||
} | ||
|
||
constexpr inline bool is_allowed(clasz_mask_t const mask, clasz const c) { | ||
auto const c_as_mask = to_mask(c); | ||
return (mask & c_as_mask) == c_as_mask; | ||
} | ||
|
||
inline std::string to_str(clasz_mask_t const x) { | ||
auto s = std::string{}; | ||
s += ", x=" + std::to_string(x); | ||
for (auto i = std::underlying_type_t<clasz>(0U); | ||
i != sizeof(clasz_mask_t) * 8; ++i) { | ||
auto const allowed = is_allowed(x, clasz{i}); | ||
s = std::string{allowed ? '1' : '0'} + s; | ||
} | ||
return s; | ||
} | ||
|
||
} // namespace nigiri::routing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.