@@ -274,9 +274,9 @@ void TrajectoryPointInterface::connectionCallback(const socket_t filedescriptor)
274274void TrajectoryPointInterface::disconnectionCallback (const socket_t filedescriptor)
275275{
276276 URCL_LOG_DEBUG (" Connection to trajectory interface dropped." );
277- if (disconnection_callback_ != nullptr )
277+ for ( auto handler : disconnect_callbacks_ )
278278 {
279- disconnection_callback_ (filedescriptor);
279+ handler. function (filedescriptor);
280280 }
281281 client_fd_ = INVALID_SOCKET;
282282}
@@ -288,9 +288,12 @@ void TrajectoryPointInterface::messageCallback(const socket_t filedescriptor, ch
288288 int32_t * status = reinterpret_cast <int *>(buffer);
289289 URCL_LOG_DEBUG (" Received message %d on TrajectoryPointInterface" , be32toh (*status));
290290
291- if (handle_trajectory_end_ )
291+ if (!trajectory_end_callbacks_. empty () )
292292 {
293- handle_trajectory_end_ (static_cast <TrajectoryResult>(be32toh (*status)));
293+ for (auto handler : trajectory_end_callbacks_)
294+ {
295+ handler.function (static_cast <TrajectoryResult>(be32toh (*status)));
296+ }
294297 }
295298 else
296299 {
@@ -303,5 +306,23 @@ void TrajectoryPointInterface::messageCallback(const socket_t filedescriptor, ch
303306 nbytesrecv);
304307 }
305308}
309+
310+ void TrajectoryPointInterface::setTrajectoryEndCallback (std::function<void (TrajectoryResult)> callback)
311+ {
312+ addTrajectoryEndCallback (callback);
313+ }
314+
315+ uint32_t TrajectoryPointInterface::addTrajectoryEndCallback (const std::function<void (TrajectoryResult)>& callback)
316+ {
317+ trajectory_end_callbacks_.push_back ({ next_done_callback_id_, callback });
318+ return next_done_callback_id_++;
319+ }
320+
321+ void TrajectoryPointInterface::removeTrajectoryEndCallback (const uint32_t handler_id)
322+ {
323+ trajectory_end_callbacks_.remove_if (
324+ [handler_id](const HandlerFunction<void (TrajectoryResult)>& h) { return h.id == handler_id; });
325+ }
326+
306327} // namespace control
307328} // namespace urcl
0 commit comments