ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
subscription.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_ocm_libdaqif_suppport
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief Contains URI support functions for daqif
7  */
8 #ifndef DAQIF_SUBSCRIPTION_HPP_
9 #define DAQIF_SUBSCRIPTION_HPP_
10 #include <memory>
11 
12 #include <daqif/uri.hpp>
13 
14 #include <mal/Mal.hpp>
15 #include <mal/ps/Subscription.hpp>
16 
17 namespace daqif {
18 
19 /**
20  * Subscription
21  */
22 template <class TopicType>
23 struct Subscription {
24  std::unique_ptr<elt::mal::ps::Subscriber<TopicType>> subscriber;
25  std::unique_ptr<elt::mal::ps::Subscription> subscription;
26 };
27 
28 /**
29  * Builder for Subscription
30  */
31 template <class TopicType, class Func>
32 auto MakeSubscription(elt::mal::Mal& mal, elt::mal::Uri const& uri, Func&& func)
34  auto subscriber = mal.getSubscriber<TopicType>(
35  elt::mal::Uri(uri), elt::mal::ps::qos::QoS::DEFAULT, elt::mal::Mal::Properties());
36  auto subscription =
37  subscriber->subscribeAsync(elt::mal::ps::DataEventFilter<TopicType>::all(), func);
38  return {std::move(subscriber), std::move(subscription)};
39 }
40 
41 } // namespace daqif
42 #endif // #ifndef DAQIF_SUBSCRIPTION_HPP_
std::unique_ptr< elt::mal::ps::Subscriber< TopicType > > subscriber
auto MakeSubscription(elt::mal::Mal &mal, elt::mal::Uri const &uri, Func &&func) -> Subscription< TopicType >
Builder for Subscription.
std::unique_ptr< elt::mal::ps::Subscription > subscription
Contains URI support functions for daqif.