RTC Toolkit  1.0.0
stateSubscriber.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_COMPONENTFRAMEWORK_STATESUBSCRIBER_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_STATESUBSCRIBER_HPP
14 
15 #include <mal/utility/Uri.hpp>
16 
17 #include <functional>
18 #include <memory>
19 #include <vector>
20 
21 namespace elt::mal::ps {
22 template <typename TOPIC_TYPE>
23 class Subscriber;
24 
25 class Subscription;
26 } // namespace elt::mal::ps
27 
28 namespace stdif {
29 class State;
30 }
31 
32 namespace rtctk::componentFramework {
33 
38 public:
39  using Callback =
40  std::function<void(double time, const std::string& name, const std::string& state)>;
41 
42  StateSubscriber(const elt::mal::Uri& uri, Callback on_state_change);
43  StateSubscriber(const std::vector<elt::mal::Uri>& uri_list, Callback on_state_change);
44 
45  // no copy allowed
46  StateSubscriber(const StateSubscriber& other) = delete;
47  StateSubscriber& operator=(const StateSubscriber& other) = delete;
48 
49  // move it instead
50  StateSubscriber(StateSubscriber&& other) = default;
52 
53  virtual ~StateSubscriber() = default;
54 
55 private:
56  std::vector<std::unique_ptr<elt::mal::ps::Subscriber<stdif::State>>> m_subscribers;
57  std::vector<std::unique_ptr<elt::mal::ps::Subscription>> m_subscriptions;
58 };
59 
60 } // namespace rtctk::componentFramework
61 
62 #endif // RTCTK_COMPONENTFRAMEWORK_STATESUBSCRIBER_HPP
rtctk::componentFramework::StateSubscriber::operator=
StateSubscriber & operator=(StateSubscriber &&other)=default
wscript.name
name
Definition: wscript:15
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::StateSubscriber::Callback
std::function< void(double time, const std::string &name, const std::string &state)> Callback
Definition: stateSubscriber.hpp:40
rtctk::componentFramework::StateSubscriber
Class used to subscribe to state-changed-topic using MAL.
Definition: stateSubscriber.hpp:37
rtctk::componentFramework::StateSubscriber::StateSubscriber
StateSubscriber(const elt::mal::Uri &uri, Callback on_state_change)
Definition: stateSubscriber.cpp:36
rtctk::componentFramework::StateSubscriber::operator=
StateSubscriber & operator=(const StateSubscriber &other)=delete
rtctk::componentFramework::StateSubscriber::StateSubscriber
StateSubscriber(StateSubscriber &&other)=default
elt::mal::ps
Definition: statePublisher.hpp:19
elt::mal::ps::Subscriber
Definition: stateSubscriber.hpp:23
stdif
Definition: statePublisher.hpp:24
rtctk::componentFramework::StateSubscriber::StateSubscriber
StateSubscriber(const StateSubscriber &other)=delete
rtctk::componentFramework::StateSubscriber::~StateSubscriber
virtual ~StateSubscriber()=default