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