#include "message_bus_impl.h" namespace robotics::v3 { message_bus_impl::message_bus_impl() { } message_bus_impl::~message_bus_impl() { map_.clear(); } message_bus_impl* message_bus_impl::instance() { static message_bus_impl g_message_bus_impl; return &g_message_bus_impl; } bool message_bus_impl::bind(std::string const& str_topic, std::any const& fn) { auto range = map_.equal_range(str_topic); if (range.first != range.second) return false; map_.emplace(str_topic, std::pair(false, fn)); return true; } void message_bus_impl::bind_multiple(std::string const& str_topic, std::any const& fn) { map_.emplace(str_topic, std::make_pair(true, fn)); } std::vector message_bus_impl::find(const std::string& str_topic) { std::vector result; auto range = map_.equal_range(str_topic); for (Iterater it = range.first; it != range.second; ++it) { result.push_back(it->second.second); } return result; } void message_bus_impl::remove(const std::string& str_topic) { auto range = map_.equal_range(str_topic); map_.erase(range.first, range.second); } }