#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 observer 指示是否作为观察者绑定的布尔值。 * @param fn 要绑定的函数对象。 * @return 如果绑定成功则返回 true,否则返回 false。 */ bool bind(std::string const& str_topic, bool observer, 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; }; }