/*** * @Description: 生产者管理类 内含3个不同主题发布者 * @Author: jizhou * @Date: 2023-07-13 19:13:44 * @LastEditors: jizhou * @LastEditTime: 2023-07-16 23:57:01 * @FilePath: /EnvironmentAccess/src/manager/IPCPublisherManager.h */ #ifndef FAST_DDS_GENERATED__IPCPublisherManager #define FAST_DDS_GENERATED__IPCPublisherManager #include #include "BaseManager.h" #include "fastdds/IPCPublisher.h" using namespace std; class IPCPublisherManager : public BaseManager { private: /*** * @brief: 构造函数 * @return {*} */ IPCPublisherManager() = default; std::map> publishers_; public: /*** * @brief: 析构函数 * @return {*} */ ~IPCPublisherManager() = default; friend class BaseManager; template std::shared_ptr> createPublisher(const std::string& topic, size_t qos_profile_depth) { auto publisher = std::make_shared>(0, topic); publishers_[topic] = publisher; return publisher; } template std::shared_ptr> getPublisherByTopic(const std::string& topic) { auto it = publishers_.find(topic); if (it != publishers_.end()) { return std::dynamic_pointer_cast>(it->second); } return nullptr; } //publish("topic",xxxxx) void stopAll() { auto iter = publishers_.begin(); for(; iter!= publishers_.end(); iter++) { iter->second->stop(); } } }; #endif