#pragma once #include "ros_bridge/include/com_private.h" #include "ros_bridge/include/RosBridgeClient.h" #include #include #include #include namespace ros_bridge { namespace com_private { struct ThreadData; class TopicPublisher { typedef std::unique_ptr ThreadPtr; using CondVar = std::condition_variable; public: TopicPublisher() = delete; TopicPublisher(RosbridgeWsClient &rbc); ~TopicPublisher(); //! @brief Starts the publisher. void start(); //! @brief Resets the publisher. void reset(); void publish(JsonDocUPtr docPtr, const char *topic); bool advertise(const char *topic, const char *type); private: using TopicMap = std::unordered_map; JsonQueue _queue; TopicMap _topicMap; std::mutex _mutex; std::shared_ptr _stopped; RosbridgeWsClient &_rbc; CondVar _cv; ThreadPtr _pThread; }; } // namespace CommunicatorDetail } // namespace ROSBridge