RTC Toolkit 6.0.0-pre2
Loading...
Searching...
No Matches
businessLogic.hpp
Go to the documentation of this file.
1
12
13#ifndef RTCTK_REUSABLECOMPONENT_MUDPIPUB_BUSINESSLOGIC_HPP
14#define RTCTK_REUSABLECOMPONENT_MUDPIPUB_BUSINESSLOGIC_HPP
15
16#include <optional>
17#include <string>
18
25#include <taiclock/taiClock.hpp>
26
28
29namespace rtctk::mudpiPub {
30
31using rtctk::componentFramework::RtcComponent;
32using rtctk::componentFramework::Runnable;
33
35
37public:
39
43
44 // for each topic we have a vector of samples, where a sample is a vector of bytes
45 using UserData = std::map<std::string, std::vector<std::vector<uint8_t>>>;
46 using UserFunc = std::function<UserData(const std::string&)>;
47
48 BusinessLogic(const std::string& name,
49 ServiceContainer& services,
50 UserFunc user_func = nullptr);
51 virtual ~BusinessLogic() = default;
52 void ActivityStarting(StopToken st) override;
53 void ActivityInitialising(StopToken st) override;
54 void ActivityRunning(StopToken st) override;
55 void ActivityUpdating(StopToken st, const JsonPayload& args) override;
56
57private:
58 using DataPointPath = rtctk::componentFramework::DataPointPath;
59 using RuntimeRepoIf = rtctk::componentFramework::RuntimeRepoIf;
60 using ComponentMetricsIf = rtctk::componentFramework::ComponentMetricsIf;
61
62 log4cplus::Logger& m_logger;
63
64 AppCfg MakeAppCfg();
65
66 void UpdateAppDynamicCfg(AppCfg& cfg);
67
68 void UpdateCachedPublicationStartTime();
69 taiclock::TaiClock::time_point ResolvePublicationStartTime() const;
70
71 void WaitUntilPublicationDeadline(taiclock::TaiClock::time_point deadline,
72 const StopToken& st) const;
73
74 std::tuple<std::string, PubCfg> MakePubCfg(const std::string& prefix, const AppCfg& app_cfg);
75
76 void
77 UpdatePubDynamicCfg(const std::string& prefix, PubDynamicCfg& pub_cfg, const AppCfg& app_cfg);
78
79 std::string m_name;
80 RuntimeRepoIf& m_rtr;
81 ComponentMetricsIf& m_metrics;
82
83 perfc::CounterI64 m_pc_samples_published;
84 perfc::ScopedRegistration m_pc_samples_published_reg;
85 std::unique_ptr<rtctk::componentFramework::FrequencyEstimator<>> m_freq_estimator;
86 std::unique_ptr<rtctk::componentFramework::DurationMonitor<>> m_dur_monitor;
87
88 AppCfg m_cfg; // configuration
89 UserFunc m_user_func;
90 std::vector<std::unique_ptr<Publisher>> m_publishers;
91
92 std::atomic<bool> m_running = false;
93
94 std::optional<taiclock::TaiClock::time_point> m_publication_start_time;
95 std::string m_publication_start_timestamp;
96};
97
98} // namespace rtctk::mudpiPub
99
100#endif // RTCTK_REUSABLECOMPONENT_MUDPIPUB_BUSINESSLOGIC_HPP
Component metrics interface.
Definition componentMetricsIf.hpp:164
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:77
Base interface for all Runtime Configuration Repository adapters.
Definition runtimeRepoIf.hpp:27
Container class that holds services of any type.
Definition serviceContainer.hpp:39
void ActivityUpdating(StopToken st, const JsonPayload &args) override
Definition businessLogic.cpp:161
std::map< std::string, std::vector< std::vector< uint8_t > > > UserData
Definition businessLogic.hpp:45
void ActivityInitialising(StopToken st) override
Definition businessLogic.cpp:43
void ActivityRunning(StopToken st) override
Definition businessLogic.cpp:122
BusinessLogic(const std::string &name, ServiceContainer &services, UserFunc user_func=nullptr)
Definition businessLogic.cpp:26
LifeCycle ComponentType
Definition businessLogic.hpp:38
rtctk::componentFramework::ServiceContainer ServiceContainer
Definition businessLogic.hpp:41
rtctk::componentFramework::JsonPayload JsonPayload
Definition businessLogic.hpp:40
rtctk::componentFramework::StopToken StopToken
Definition businessLogic.hpp:42
std::function< UserData(const std::string &)> UserFunc
Definition businessLogic.hpp:46
void ActivityStarting(StopToken st) override
Definition businessLogic.cpp:36
virtual ~BusinessLogic()=default
Header file for ComponentMetricsIf.
Header file for Duration Monitor.
Header file for Frequency Estimator.
rad::StopToken StopToken
Definition stopToken.hpp:20
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:25
Definition businessLogic.cpp:24
Runnable< RtcComponent > LifeCycle
Definition businessLogic.hpp:34
RTC toolkit MUDPI publisher class declaration.
Lifecycle of a basic 'RtcComponent'.
Lifecycle Extension that makes an RTC Component 'Runnable'.
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.
Life cycle extension to make RtcComponent Runnable.
Definition runnable.hpp:31
Configuration of entire MUDPI Publisher application.
Definition config.hpp:84
Dynamic Configuration of a single MUDPI Publisher object.
Definition config.hpp:29