SMACC
Loading...
Searching...
No Matches
cb_default_publish_loop.h
Go to the documentation of this file.
1
2#pragma once
5
6namespace cl_ros_publisher
7{
8
11{
12private:
13 std::function<void()> deferedPublishFn;
15
16public:
18 : deferedPublishFn(nullptr)
19 {
20 }
21
22 template <typename TMessage>
23 CbDefaultPublishLoop(const TMessage &data)
24 {
25 this->setMessage(data);
26 }
27
28 template <typename TMessage>
29 void setMessage(const TMessage &data)
30 {
31 deferedPublishFn = [=]() {
32 client_->publish(data);
33 };
34 }
35
36 virtual void onEntry() override
37 {
38 this->requiresClient(client_);
39 }
40
41 virtual void update()
42 {
43 if (deferedPublishFn != nullptr)
45 }
46
47 virtual void onExit() override
48 {
49 }
50};
51} // namespace cl_ros_publisher
void publish(const MessageType &msg)
void requiresClient(SmaccClientType *&storage)