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