17 std::uint32_t
hash = 2166136261u;
18 for (
const char ch : value)
20 hash ^=
static_cast<std::uint8_t
>(
ch);
27 bool StreamRegistry::Key::operator==(
const Key&
other)
const noexcept
29 return receiver_id ==
other.receiver_id && receiver_name ==
other.receiver_name && mode ==
other.mode;
32 std::size_t StreamRegistry::KeyHash::operator()(
const Key&
key)
const noexcept
34 return static_cast<std::size_t
>(initialStreamId(
key));
40 if (
const auto found = _by_key.find(
key);
found != _by_key.end())
45 std::uint32_t stream_id = initialStreamId(
key);
52 if (!_by_stream_id.contains(stream_id))
54 _by_key.emplace(
key, stream_id);
55 _by_stream_id.emplace(stream_id,
key);
56 _descriptors.emplace(stream_id, stream);
59 stream_id = (stream_id & 0x7FFFFFFFu) + 1u;
62 throw std::runtime_error(
"Unable to allocate collision-free VITA stream ID");
69 const auto found = _descriptors.find(stream_id);
70 if (
found == _descriptors.end())
72 throw std::out_of_range(
"Unknown VITA stream ID");
77 std::uint32_t StreamRegistry::initialStreamId(
const Key&
key)
noexcept
79 const std::string
material = std::to_string(
key.receiver_id) +
":" +
key.receiver_name +
":" +
key.mode;
const core::ReceiverStreamDescriptor & descriptor(std::uint32_t stream_id) const
bool contains(std::uint32_t stream_id) const
std::uint32_t registerStream(const core::ReceiverStreamDescriptor &stream)
std::string receiver_name