RTC Toolkit  0.1.0-alpha
main.hpp
Go to the documentation of this file.
1 
8 #ifndef RTCTK_TELSUB_MAIN_HPP
9 #define RTCTK_TELSUB_MAIN_HPP
10 
11 #include <memory>
17 
18 namespace rtctk::telSub {
19 
34 template <class UserTopicType, class DataBlender>
35 void Main(const rtctk::componentFramework::Args& args, DataBlender&& blender ) noexcept {
36  auto factory =
37  [blender = std::forward<DataBlender>(blender)](
38  std::string const& name,
39  componentFramework::ServiceContainer& services) -> std::unique_ptr<BusinessLogic> {
40  // Operational Logic factory.
41  // This takes ownership of `blender` and instances created from factory will only receive a
42  // reference. (TBD) (this requires a stateless DataBlender).
43  // If DataBlender is stateful with configuration params then this means that new instances
44  // should be created for each new instance of OperationalLogic?
45  auto op_logic_factory =
46  [blender = std::move(blender)](OperationalLogicFactoryParams const& params)
47  -> std::unique_ptr<OperationalLogicIf> {
48  auto dds_subscriber = std::make_unique<DdsSubscriber>(params.dds_params);
49  auto correlator = std::make_unique<Correlator>(std::move(dds_subscriber));
50  auto writer = ipcq::Writer<UserTopicType>(params.shm_params.topic_name.c_str(),
51  params.shm_params.capacity,
52  params.shm_params.mem_policy);
53  auto shm_publisher = MakeShmPublisher<UserTopicType>(std::move(writer), blender);
54  return std::make_unique<OperationalLogic>(
55  params.operational_params, std::move(correlator), std::move(shm_publisher));
56  };
57 
58  return std::make_unique<BusinessLogic>(name, services, std::move(op_logic_factory));
59  };
60  componentFramework::RunAsRtcComponent<BusinessLogic>(args, std::move(factory));
61 }
62 
63 } // namespace rtctk::telSub
64 #endif // #ifndef RTCTK_TELSUB_MAIN_HPP
rtctk::telSub::OperationalLogicFactoryParams
Set of all parameters needed when constructing the OperationalLogic object.
Definition: businessLogic.hpp:28
rtctk::componentFramework::detail::Args
Definition: rtcComponent.hpp:34
rtctk::telSub::Main
void Main(const rtctk::componentFramework::Args &args, DataBlender &&blender) noexcept
Definition: main.hpp:35
shmPublisher.hpp
Declares ShmPublisher.
ddsSubscriber.hpp
Declares the DdsSubscriber implementation.
rtctk::componentFramework::ServiceContainer
Definition: serviceContainer.hpp:31
rtctk::telSub
Definition: businessLogic.cpp:35
correlator.hpp
Declares Correlator.
rtcComponent.hpp
Provides core functionality of an RTC Component.
businessLogic.hpp
Implements the business logic for telSub.