FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
serial::vita49::StreamRegistry Class Reference

#include "stream_registry.h"

Public Member Functions

std::uint32_t registerStream (const core::ReceiverStreamDescriptor &stream)
 
bool contains (std::uint32_t stream_id) const
 
const core::ReceiverStreamDescriptordescriptor (std::uint32_t stream_id) const
 

Detailed Description

Definition at line 17 of file stream_registry.h.

Member Function Documentation

◆ contains()

bool serial::vita49::StreamRegistry::contains ( std::uint32_t  stream_id) const

Definition at line 65 of file stream_registry.cpp.

65{ return _by_stream_id.contains(stream_id); }

◆ descriptor()

const core::ReceiverStreamDescriptor & serial::vita49::StreamRegistry::descriptor ( std::uint32_t  stream_id) const

Definition at line 67 of file stream_registry.cpp.

68 {
69 const auto found = _descriptors.find(stream_id);
70 if (found == _descriptors.end())
71 {
72 throw std::out_of_range("Unknown VITA stream ID");
73 }
74 return found->second;
75 }
math::Vec3 max

References max.

◆ registerStream()

std::uint32_t serial::vita49::StreamRegistry::registerStream ( const core::ReceiverStreamDescriptor stream)

Definition at line 37 of file stream_registry.cpp.

38 {
39 Key key{.receiver_id = stream.receiver_id, .receiver_name = stream.receiver_name, .mode = stream.mode};
40 if (const auto found = _by_key.find(key); found != _by_key.end())
41 {
42 return found->second;
43 }
44
45 std::uint32_t stream_id = initialStreamId(key);
46 for (std::uint32_t attempts = 0; attempts < 0x7FFFFFFFu; ++attempts)
47 {
48 if (stream_id == 0)
49 {
50 stream_id = 1;
51 }
52 if (!_by_stream_id.contains(stream_id))
53 {
54 _by_key.emplace(key, stream_id);
55 _by_stream_id.emplace(stream_id, key);
56 _descriptors.emplace(stream_id, stream);
57 return stream_id;
58 }
59 stream_id = (stream_id & 0x7FFFFFFFu) + 1u;
60 }
61
62 throw std::runtime_error("Unable to allocate collision-free VITA stream ID");
63 }

References max, core::ReceiverStreamDescriptor::mode, core::ReceiverStreamDescriptor::receiver_id, and core::ReceiverStreamDescriptor::receiver_name.

Referenced by serial::vita49::Vita49OutputSink::registerStream().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: