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