17 #ifndef CYBER_TRANSPORT_DISPATCHER_RTPS_DISPATCHER_H_ 18 #define CYBER_TRANSPORT_DISPATCHER_RTPS_DISPATCHER_H_ 24 #include <unordered_map> 41 eprosima::fastrtps::Subscriber*
sub;
52 void Shutdown()
override;
54 template <
typename MessageT>
55 void AddListener(
const RoleAttributes& self_attr,
58 template <
typename MessageT>
59 void AddListener(
const RoleAttributes& self_attr,
60 const RoleAttributes& opposite_attr,
64 participant_ = participant;
68 void OnMessage(uint64_t channel_id,
69 const std::shared_ptr<std::string>& msg_str,
71 void AddSubscriber(
const RoleAttributes& self_attr);
73 std::unordered_map<uint64_t, Subscriber> subs_;
74 std::mutex subs_mutex_;
81 template <
typename MessageT>
84 auto listener_adapter = [listener](
85 const std::shared_ptr<std::string>& msg_str,
87 auto msg = std::make_shared<MessageT>();
89 listener(msg, msg_info);
92 Dispatcher::AddListener<std::string>(self_attr, listener_adapter);
93 AddSubscriber(self_attr);
96 template <
typename MessageT>
98 const RoleAttributes& opposite_attr,
100 auto listener_adapter = [listener](
101 const std::shared_ptr<std::string>& msg_str,
103 auto msg = std::make_shared<MessageT>();
105 listener(msg, msg_info);
108 Dispatcher::AddListener<std::string>(self_attr, opposite_attr,
110 AddSubscriber(self_attr);
117 #endif // CYBER_TRANSPORT_DISPATCHER_RTPS_DISPATCHER_H_ SubListenerPtr sub_listener
Definition: rtps_dispatcher.h:42
Subscriber()
Definition: rtps_dispatcher.h:39
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: rtps_dispatcher.h:48
#define RETURN_IF(condition)
Definition: log.h:106
void AddListener(const RoleAttributes &self_attr, const MessageListener< MessageT > &listener)
Definition: rtps_dispatcher.h:82
void set_participant(const ParticipantPtr &participant)
Definition: rtps_dispatcher.h:63
Definition: dispatcher.h:54
#define DECLARE_SINGLETON(classname)
Definition: macros.h:52
std::shared_ptr< SubListener > SubListenerPtr
Definition: sub_listener.h:39
std::enable_if< HasParseFromString< T >::value, bool >::type ParseFromString(const std::string &str, T *message)
Definition: message_traits.h:158
Definition: message_info.h:30
std::function< void(const std::shared_ptr< MessageT > &, const MessageInfo &)> MessageListener
Definition: dispatcher.h:52
eprosima::fastrtps::Subscriber * sub
Definition: rtps_dispatcher.h:41
std::shared_ptr< Participant > ParticipantPtr
Definition: participant.h:37
Definition: rtps_dispatcher.h:38