zxs hai 2 semanas
pai
achega
03b2a22cae
Modificáronse 1 ficheiros con 4 adicións e 4 borrados
  1. 4 4
      robot/robotics/message_bus.hpp

+ 4 - 4
robot/robotics/message_bus.hpp

@@ -66,7 +66,7 @@ namespace robotics {
 			 * @brief 发送消息
 			 * @param str_topic
 			 */
-			template<typename _Ret,typename _BCast>
+			template<typename _Ret,bool _BCast = false>
 			_Ret invoke(const std::string& str_topic) {
 				using function_type = std::function<_Ret()>;
 				std::string str_msg_type = str_topic + typeid(function_type).name();
@@ -100,7 +100,7 @@ namespace robotics {
 			 * @param str_topic
 			 * @param ...args
 			 */
-			template<typename _Ret, typename _BCast,typename... _Args>
+			template<typename _Ret, bool _BCast = false,typename... _Args>
 			_Ret invoke(const std::string& str_topic, _Args ...args) {
 				using function_type = std::function<_Ret(_Args...)>;
 				std::string str_msg_type = str_topic + typeid(function_type).name();
@@ -150,9 +150,9 @@ namespace robotics {
 			 * @return 
 			 */
 			template<typename _Fn>
-			bool add(const std::string& str_topic, _Fn&& f) {
+			bool add(const std::string& str_topic, bool observer, _Fn&& f) {
 				std::string str_msg_type = str_topic + typeid(f).name();
-				return message_bus_impl_->bind(str_msg_type, std::forward<_Fn>(f));
+				return message_bus_impl_->bind(str_msg_type, observer, std::forward<_Fn>(f));
 			}
 		private:
 			message_bus_impl* message_bus_impl_ = nullptr;