#pragma once #ifdef WINDOWS_BUILD #ifdef MESSAGE_BUS_EXPORTS #define MESSAGE_BUS_IMPL _declspec(dllexport) #else #define MESSAGE_BUS_IMPL _declspec(dllimport) #endif #endif //stl #include #include #include #include namespace robotics::v3 { #ifdef WINDOWS_BUILD class MESSAGE_BUS_IMPL message_bus_impl { #elif LINUX_BUILD class message_bus_impl { #endif public: /** * @brief 单例 * @return */ static message_bus_impl* instance(); ~message_bus_impl(); /** * @brief 绑定单个函数 * @param str_topic * @param fn * @return */ bool bind(std::string const& str_topic, std::any const& fn); /** * @brief 绑定多个函数 * @param str_topic * @param fn */ void bind_multiple(std::string const& str_topic, std::any const& fn); /** * @brief 查找 * @param str_topic * @return */ std::vector find(const std::string& str_topic); /** * @brief 删除 * @param str_topic */ void remove(const std::string& str_topic); private: message_bus_impl(); private: std::multimap> map_; typedef std::multimap>::iterator Iterater; }; }