RTC Toolkit  0.1.0-alpha
operationalLogic.hpp
Go to the documentation of this file.
1 
8 #ifndef RTCKT_TELSUB_OPERATIONALLOGIC_HPP
9 #define RTCKT_TELSUB_OPERATIONALLOGIC_HPP
10 #include <atomic>
11 #include <mutex>
12 #include <chrono>
13 #include <optional>
14 #include <thread>
15 
16 #include "operationalLogicIf.hpp"
17 #include "shmPublisherIf.hpp"
18 #include "correlatorIf.hpp"
19 
20 namespace rtctk::telSub {
21 
64 class OperationalLogic final : public OperationalLogicIf {
65 public:
71  std::unique_ptr<CorrelatorIf>&& correlator,
72  std::unique_ptr<ShmPublisherIf>&& shm_publisher);
73 
78 
86  void RunAsync() RTCTK_NOEXCEPT override;
87 
93  void IdleAsync() RTCTK_NOEXCEPT override;
94 
95  std::error_code GetLastError() const RTCTK_NOEXCEPT override;
96  uint64_t GetErrorCount() const RTCTK_NOEXCEPT override;
97 
98 private:
99  enum class State : int { Idle=0, Run, Exit };
100 
104  void ProcessingLoop();
108  void MonitoringLoop();
109 
110  OperationalParams const m_params;
125  std::mutex mutable m_error_mutex;
126  std::error_code m_last_error;
127  uint64_t m_error_count;
128  std::thread m_monitoring_thread;
134  std::atomic<State> m_requested_state;
135  std::unique_ptr<CorrelatorIf> m_correlator;
136  std::unique_ptr<ShmPublisherIf> m_shm_publisher;
137  std::thread m_processing_thread;
139 };
140 
141 } // namespace rtctk::telSub
142 #endif // #ifndef RTCKT_TELSUB_OPERATIONALLOGIC_HPP
rtctk::telSub::OperationalLogic::GetLastError
std::error_code GetLastError() const RTCTK_NOEXCEPT override
Definition: operationalLogic.cpp:68
rtctk::telSub::OperationalLogicIf
Definition: operationalLogicIf.hpp:55
shmPublisherIf.hpp
Declares ShmPublisher.
rtctk::telSub::OperationalLogic::OperationalLogic
OperationalLogic(OperationalParams params, std::unique_ptr< CorrelatorIf > &&correlator, std::unique_ptr< ShmPublisherIf > &&shm_publisher)
Definition: operationalLogic.cpp:19
operationalLogicIf.hpp
Declares OperationalLogicIf.
rtctk::telSub
Definition: businessLogic.cpp:35
rtctk::telSub::OperationalParams
Definition: operationalLogicIf.hpp:37
correlatorIf.hpp
Declares CorrelatorIf.
RTCTK_NOEXCEPT
#define RTCTK_NOEXCEPT
Definition: config.hpp:12
rtctk::telSub::OperationalLogic::GetErrorCount
uint64_t GetErrorCount() const RTCTK_NOEXCEPT override
Definition: operationalLogic.cpp:73
rtctk::telSub::OperationalLogic::IdleAsync
void IdleAsync() RTCTK_NOEXCEPT override
Definition: operationalLogic.cpp:64
rtctk::telSub::OperationalLogic::RunAsync
void RunAsync() RTCTK_NOEXCEPT override
Definition: operationalLogic.cpp:56
rtctk::telSub::OperationalLogic::~OperationalLogic
~OperationalLogic()
Definition: operationalLogic.cpp:43
rtctk::telSub::OperationalLogic
Definition: operationalLogic.hpp:64