RTC Toolkit  2.0.0
correlator.hpp
Go to the documentation of this file.
1 
11 #ifndef RTCTK_TELSUB_CORRELATOR_HPP
12 #define RTCTK_TELSUB_CORRELATOR_HPP
13 
14 #include <memory>
17 
18 namespace rtctk::telSub {
19 
28 class Correlator final : public CorrelatorIf {
29 public:
30  using Alloc = std::pmr::polymorphic_allocator<std::byte>;
31 
35  explicit Correlator(CorrelatorParams const& params,
36  std::unique_ptr<DdsWaitSetIf> dds_subscriber,
37  Alloc const& alloc = {});
38 
46  virtual std::error_code Poll(std::chrono::milliseconds timeout,
47  DataSamplesView const*& samples) RTCTK_NOEXCEPT override;
48 
49  std::optional<unsigned long> GetLastSampleId() const RTCTK_NOEXCEPT override {
50  return m_last_correlated_sample;
51  }
52  void Reset() RTCTK_NOEXCEPT override;
53 private:
54  using ClockType = std::chrono::steady_clock;
55  using TimePoint = ClockType::time_point;
56 
60  std::error_code TakeUntil(TimePoint until) noexcept;
61 
66  std::error_code CorrelateFirst(TimePoint until, DataSamplesView const*& samples) noexcept;
67 
78  std::error_code CorrelateSubsequent(TimePoint until, DataSamplesView const*& samples) noexcept;
79 
83  void Truncate(AgnosticDataSamples& samples) noexcept;
84 
85  CorrelatorParams m_params;
86  std::unique_ptr<DdsWaitSetIf> m_dds_subscriber;
87  AgnosticDataSamples& m_samples;
88  std::optional<unsigned long> m_last_correlated_sample;
89  TimePoint m_poll_until_time;
90  DataSamplesView m_view;
91  std::pmr::vector<size_t> m_indices;
92 };
93 
94 } // namespace rtctk::telSub
95 
96 #endif // #define RTCTK_TELSUB_CORRELATOR_HPP
rtctk::telSub::Correlator::Reset
void Reset() RTCTK_NOEXCEPT override
Resets internal state.
Definition: correlator.cpp:132
rtctk::telSub::CorrelatorIf
Interface for correlator implemementations that takes new data samples from DDS and performs correlat...
Definition: correlatorIf.hpp:38
rtctk::telSub::Correlator
Implements a correlator.
Definition: correlator.hpp:28
rtctk::telSub::Correlator::GetLastSampleId
std::optional< unsigned long > GetLastSampleId() const RTCTK_NOEXCEPT override
Definition: correlator.hpp:49
rtctk::telSub::Correlator::Poll
virtual std::error_code Poll(std::chrono::milliseconds timeout, DataSamplesView const *&samples) RTCTK_NOEXCEPT override
The strategy is to correlate on existing data, if possible before taking more samples.
Definition: correlator.cpp:141
rtctk::telSub::CorrelatorParams
Placeholder for correlator parameters.
Definition: correlatorIf.hpp:29
rtctk::telSub::DataSamplesView
A set of correlated agnostic non-owning data samples references.
Definition: dataSampleView.hpp:46
ddsWaitSetIf.hpp
Declares DdsWaitSetIf.
rtctk::telSub
Definition: main.cpp:6
rtctk::telSub::DdsWaitSetIf
Base class abstracting DDS communication code.
Definition: ddsWaitSetIf.hpp:58
correlatorIf.hpp
Declares CorrelatorIf.
std
Definition: mudpiProcessingError.hpp:119
rtctk::telSub::Correlator::Correlator
Correlator(CorrelatorParams const &params, std::unique_ptr< DdsWaitSetIf > dds_subscriber, Alloc const &alloc={})
Definition: correlator.cpp:118
RTCTK_NOEXCEPT
#define RTCTK_NOEXCEPT
Definition: config.hpp:15
rtctk::telSub::Correlator::Alloc
std::pmr::polymorphic_allocator< std::byte > Alloc
Definition: correlator.hpp:30
rtctk::telSub::AgnosticDataSamples
Container of DDS samples and associated sample information.
Definition: agnosticDataSamples.hpp:71