MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
ParameterResolver.hpp
Go to the documentation of this file.
1#pragma once
2
4
5/** @brief How one source maps to a network's elements. */
6enum class MappingMode : uint8_t {
7 BROADCAST, ///< One source value applies to every network element
8 ONE_TO_ONE ///< Source elements correspond to network elements
9};
10
11/** @brief Hash a parameter name once when installing a mapping. */
12[[nodiscard]] constexpr uint64_t parameter_hash(std::string_view name) noexcept
13{
14 uint64_t hash = 14695981039346656037ULL;
15 for (unsigned char character : name) {
16 hash ^= character;
17 hash *= 1099511628211ULL;
18 }
19 return hash;
20}
21
22/** @brief A cached hash paired with its original name for collision-safe matching. */
24 std::string_view name;
25 uint64_t hash;
26
27 [[nodiscard]] constexpr bool matches(std::string_view candidate) const noexcept
28 {
29 return hash == parameter_hash(candidate) && name == candidate;
30 }
31};
32
33[[nodiscard]] constexpr ParameterKey parameter_key(std::string_view name) noexcept
34{
35 return { name, parameter_hash(name) };
36}
37
38} // namespace MayaFlux::Nodes::Network
constexpr uint64_t parameter_hash(std::string_view name) noexcept
Hash a parameter name once when installing a mapping.
constexpr ParameterKey parameter_key(std::string_view name) noexcept
MappingMode
How one source maps to a network's elements.
@ ONE_TO_ONE
Source elements correspond to network elements.
@ BROADCAST
One source value applies to every network element.
constexpr bool matches(std::string_view candidate) const noexcept
A cached hash paired with its original name for collision-safe matching.