Skip to content

Commit 5539d43

Browse files
alsoraskyegalaxy
authored andcommitted
add override attribute to some ipc methods
Signed-off-by: Alberto Soragna <[email protected]>
1 parent d2b4bce commit 5539d43

File tree

7 files changed

+112
-117
lines changed

7 files changed

+112
-117
lines changed

rclcpp/include/rclcpp/experimental/action_client_intra_process_base.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,23 @@ class ActionClientIntraProcessBase : public rclcpp::Waitable
6565

6666
RCLCPP_PUBLIC
6767
size_t
68-
get_number_of_ready_guard_conditions() {return 1;}
68+
get_number_of_ready_guard_conditions() override {return 1;}
6969

7070
RCLCPP_PUBLIC
7171
void
72-
add_to_wait_set(rcl_wait_set_t & wait_set);
72+
add_to_wait_set(rcl_wait_set_t & wait_set) override;
7373

74-
virtual bool
75-
is_ready(const rcl_wait_set_t & wait_set) = 0;
74+
bool
75+
is_ready(const rcl_wait_set_t & wait_set) override = 0;
7676

77-
virtual
7877
std::shared_ptr<void>
79-
take_data() = 0;
78+
take_data() override = 0;
8079

81-
virtual
8280
std::shared_ptr<void>
83-
take_data_by_entity_id(size_t id) = 0;
81+
take_data_by_entity_id(size_t id) override = 0;
8482

85-
virtual void
86-
execute(const std::shared_ptr<void> & data) = 0;
83+
void
84+
execute(const std::shared_ptr<void> & data) override = 0;
8785

8886
RCLCPP_PUBLIC
8987
const char *

rclcpp/include/rclcpp/experimental/action_server_intra_process_base.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,23 @@ class ActionServerIntraProcessBase : public rclcpp::Waitable
6464

6565
RCLCPP_PUBLIC
6666
size_t
67-
get_number_of_ready_guard_conditions() {return 1;}
67+
get_number_of_ready_guard_conditions() override {return 1;}
6868

6969
RCLCPP_PUBLIC
7070
void
71-
add_to_wait_set(rcl_wait_set_t & wait_set);
71+
add_to_wait_set(rcl_wait_set_t & wait_set) override;
7272

73-
virtual bool
74-
is_ready(const rcl_wait_set_t & wait_set) = 0;
73+
bool
74+
is_ready(const rcl_wait_set_t & wait_set) override = 0;
7575

76-
virtual
7776
std::shared_ptr<void>
78-
take_data() = 0;
77+
take_data() override = 0;
7978

80-
virtual
8179
std::shared_ptr<void>
82-
take_data_by_entity_id(size_t id) = 0;
80+
take_data_by_entity_id(size_t id) override = 0;
8381

84-
virtual void
85-
execute(const std::shared_ptr<void> & data) = 0;
82+
void
83+
execute(const std::shared_ptr<void> & data) override = 0;
8684

8785
RCLCPP_PUBLIC
8886
const char *

rclcpp/include/rclcpp/experimental/client_intra_process_base.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,17 @@ class ClientIntraProcessBase : public rclcpp::Waitable
5656

5757
RCLCPP_PUBLIC
5858
size_t
59-
get_number_of_ready_guard_conditions() {return 1;}
59+
get_number_of_ready_guard_conditions() override {return 1;}
6060

6161
RCLCPP_PUBLIC
6262
void
63-
add_to_wait_set(rcl_wait_set_t & wait_set);
63+
add_to_wait_set(rcl_wait_set_t & wait_set) override;
6464

65-
virtual bool
66-
is_ready(const rcl_wait_set_t & wait_set) = 0;
65+
bool
66+
is_ready(const rcl_wait_set_t & wait_set) override = 0;
6767

68-
virtual
6968
std::shared_ptr<void>
70-
take_data() = 0;
69+
take_data() override = 0;
7170

7271
std::shared_ptr<void>
7372
take_data_by_entity_id(size_t id) override
@@ -76,8 +75,8 @@ class ClientIntraProcessBase : public rclcpp::Waitable
7675
return take_data();
7776
}
7877

79-
virtual void
80-
execute(const std::shared_ptr<void> & data) = 0;
78+
void
79+
execute(const std::shared_ptr<void> & data) override = 0;
8180

8281
RCLCPP_PUBLIC
8382
const char *

rclcpp/include/rclcpp/experimental/service_intra_process_base.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,17 @@ class ServiceIntraProcessBase : public rclcpp::Waitable
6060

6161
RCLCPP_PUBLIC
6262
size_t
63-
get_number_of_ready_guard_conditions() {return 1;}
63+
get_number_of_ready_guard_conditions() override {return 1;}
6464

6565
RCLCPP_PUBLIC
6666
void
67-
add_to_wait_set(rcl_wait_set_t & wait_set);
67+
add_to_wait_set(rcl_wait_set_t & wait_set) override;
6868

69-
virtual bool
70-
is_ready(const rcl_wait_set_t & wait_set) = 0;
69+
bool
70+
is_ready(const rcl_wait_set_t & wait_set) override = 0;
7171

72-
virtual
7372
std::shared_ptr<void>
74-
take_data() = 0;
73+
take_data() override = 0;
7574

7675
std::shared_ptr<void>
7776
take_data_by_entity_id(size_t id) override
@@ -80,8 +79,8 @@ class ServiceIntraProcessBase : public rclcpp::Waitable
8079
return take_data();
8180
}
8281

83-
virtual void
84-
execute(const std::shared_ptr<void> & data) = 0;
82+
void
83+
execute(const std::shared_ptr<void> & data) override = 0;
8584

8685
RCLCPP_PUBLIC
8786
const char *

rclcpp_action/include/rclcpp_action/client.hpp

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class ClientBase : public rclcpp::Waitable
195195
rclcpp::Waitable::SharedPtr
196196
get_intra_process_waitable();
197197

198-
protected:
198+
protected:
199199
RCLCPP_ACTION_PUBLIC
200200
ClientBase(
201201
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
@@ -316,7 +316,7 @@ class ClientBase : public rclcpp::Waitable
316316
setup_intra_process(
317317
uint64_t ipc_action_client_id,
318318
IntraProcessManagerWeakPtr weak_ipm);
319-
319+
320320
// End API for communication between ClientBase and Client<>
321321
// ---------------------------------------------------------
322322

@@ -508,36 +508,36 @@ class Client : public ClientBase
508508
}
509509
};
510510

511-
bool intra_process_send_done = false;
512-
513-
std::lock_guard<std::recursive_mutex> lock(ipc_mutex_);
514-
515-
if (use_intra_process_) {
516-
auto ipm = weak_ipm_.lock();
517-
if (!ipm) {
518-
throw std::runtime_error(
511+
bool intra_process_send_done = false;
512+
513+
std::lock_guard<std::recursive_mutex> lock(ipc_mutex_);
514+
515+
if (use_intra_process_) {
516+
auto ipm = weak_ipm_.lock();
517+
if (!ipm) {
518+
throw std::runtime_error(
519519
"intra process send goal called after destruction of intra process manager");
520-
}
521-
bool intra_process_server_available = ipm->action_server_is_available(ipc_action_client_id_);
522-
520+
}
521+
bool intra_process_server_available = ipm->action_server_is_available(ipc_action_client_id_);
522+
523523
// Check if there's an intra-process action server available matching this client.
524524
// If there's not, we fall back into inter-process communication, since
525525
// the server might be available in another process or was configured to not use IPC.
526-
if (intra_process_server_available) {
527-
ipm->intra_process_action_send_goal_request<ActionT>(
526+
if (intra_process_server_available) {
527+
ipm->intra_process_action_send_goal_request<ActionT>(
528528
ipc_action_client_id_,
529529
std::move(goal_request),
530530
callback);
531-
intra_process_send_done = true;
532-
}
531+
intra_process_send_done = true;
533532
}
534-
535-
if (!intra_process_send_done) {
533+
}
534+
535+
if (!intra_process_send_done) {
536536
// Send inter-process goal request
537-
this->send_goal_request(
537+
this->send_goal_request(
538538
std::static_pointer_cast<void>(goal_request),
539539
callback);
540-
}
540+
}
541541

542542
// TODO(jacobperron): Encapsulate into it's own function and
543543
// consider exposing an option to disable this cleanup
@@ -848,53 +848,53 @@ class Client : public ClientBase
848848
// The client callback to be called when server calculates the result, using the server
849849
// response as argument.
850850
auto callback =
851-
[goal_handle, this](std::shared_ptr<void> response) mutable
852-
{
851+
[goal_handle, this](std::shared_ptr<void> response) mutable
852+
{
853853
// Wrap the response in a struct with the fields a user cares about
854-
WrappedResult wrapped_result;
855-
using GoalResultResponse = typename ActionT::Impl::GetResultService::Response;
856-
auto result_response = std::static_pointer_cast<GoalResultResponse>(response);
857-
wrapped_result.result = std::make_shared<typename ActionT::Result>();
858-
*wrapped_result.result = result_response->result;
859-
wrapped_result.goal_id = goal_handle->get_goal_id();
860-
wrapped_result.code = static_cast<ResultCode>(result_response->status);
861-
goal_handle->set_result(wrapped_result);
862-
std::lock_guard<std::recursive_mutex> lock(goal_handles_mutex_);
863-
goal_handles_.erase(goal_handle->get_goal_id());
864-
};
865-
866-
try {
867-
bool intra_process_send_done = false;
868-
869-
std::lock_guard<std::recursive_mutex> lock(ipc_mutex_);
870-
871-
if (use_intra_process_) {
872-
auto ipm = weak_ipm_.lock();
873-
if (!ipm) {
874-
throw std::runtime_error(
854+
WrappedResult wrapped_result;
855+
using GoalResultResponse = typename ActionT::Impl::GetResultService::Response;
856+
auto result_response = std::static_pointer_cast<GoalResultResponse>(response);
857+
wrapped_result.result = std::make_shared<typename ActionT::Result>();
858+
*wrapped_result.result = result_response->result;
859+
wrapped_result.goal_id = goal_handle->get_goal_id();
860+
wrapped_result.code = static_cast<ResultCode>(result_response->status);
861+
goal_handle->set_result(wrapped_result);
862+
std::lock_guard<std::recursive_mutex> lock(goal_handles_mutex_);
863+
goal_handles_.erase(goal_handle->get_goal_id());
864+
};
865+
866+
try {
867+
bool intra_process_send_done = false;
868+
869+
std::lock_guard<std::recursive_mutex> lock(ipc_mutex_);
870+
871+
if (use_intra_process_) {
872+
auto ipm = weak_ipm_.lock();
873+
if (!ipm) {
874+
throw std::runtime_error(
875875
"intra process send result called after destruction of intra process manager");
876-
}
877-
bool intra_process_server_available =
878-
ipm->action_server_is_available(ipc_action_client_id_);
879-
876+
}
877+
bool intra_process_server_available =
878+
ipm->action_server_is_available(ipc_action_client_id_);
879+
880880
// Check if there's an intra-process action server available matching this client.
881881
// If there's not, we fall back into inter-process communication, since
882882
// the server might be available in another process or was configured to not use IPC.
883-
if (intra_process_server_available) {
884-
ipm->intra_process_action_send_result_request<ActionT>(
883+
if (intra_process_server_available) {
884+
ipm->intra_process_action_send_result_request<ActionT>(
885885
ipc_action_client_id_,
886886
std::move(goal_result_request),
887887
callback);
888-
intra_process_send_done = true;
889-
}
890-
}
891-
892-
if (!intra_process_send_done) {
888+
intra_process_send_done = true;
889+
}
890+
}
891+
892+
if (!intra_process_send_done) {
893893
// Send inter-process result request
894-
this->send_result_request(
894+
this->send_result_request(
895895
std::static_pointer_cast<void>(goal_result_request),
896896
callback);
897-
}
897+
}
898898
} catch (rclcpp::exceptions::RCLError & ex) {
899899
// This will cause an exception when the user tries to access the result
900900
goal_handle->invalidate(exceptions::UnawareGoalHandleError(ex.message));
@@ -921,35 +921,35 @@ class Client : public ClientBase
921921
}
922922
};
923923

924-
bool intra_process_send_done = false;
925-
926-
std::lock_guard<std::recursive_mutex> lock(ipc_mutex_);
927-
928-
if (use_intra_process_) {
929-
auto ipm = weak_ipm_.lock();
930-
if (!ipm) {
931-
throw std::runtime_error(
924+
bool intra_process_send_done = false;
925+
926+
std::lock_guard<std::recursive_mutex> lock(ipc_mutex_);
927+
928+
if (use_intra_process_) {
929+
auto ipm = weak_ipm_.lock();
930+
if (!ipm) {
931+
throw std::runtime_error(
932932
"intra process send goal called after destruction of intra process manager");
933-
}
934-
bool intra_process_server_available = ipm->action_server_is_available(ipc_action_client_id_);
935-
933+
}
934+
bool intra_process_server_available = ipm->action_server_is_available(ipc_action_client_id_);
935+
936936
// Check if there's an intra-process action server available matching this client.
937937
// If there's not, we fall back into inter-process communication, since
938938
// the server might be available in another process or was configured to not use IPC.
939-
if (intra_process_server_available) {
940-
ipm->intra_process_action_send_cancel_request<ActionT>(
939+
if (intra_process_server_available) {
940+
ipm->intra_process_action_send_cancel_request<ActionT>(
941941
ipc_action_client_id_,
942942
std::move(cancel_request),
943943
callback);
944-
intra_process_send_done = true;
945-
}
944+
intra_process_send_done = true;
946945
}
947-
948-
if (!intra_process_send_done) {
949-
this->send_cancel_request(
946+
}
947+
948+
if (!intra_process_send_done) {
949+
this->send_cancel_request(
950950
std::static_pointer_cast<void>(cancel_request),
951951
callback);
952-
}
952+
}
953953
return future;
954954
}
955955

rclcpp_action/include/rclcpp_action/server.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class ServerBase : public rclcpp::Waitable
304304
RCLCPP_ACTION_PUBLIC
305305
std::shared_ptr<void>
306306
get_result_response(GoalUUID uuid);
307-
307+
308308
// End API for communication between ServerBase and Server<>
309309
// ---------------------------------------------------------
310310

@@ -701,9 +701,9 @@ class Server : public ServerBase, public std::enable_shared_from_this<Server<Act
701701
ipm->remove_intra_process_action_client_goal_uuid(hashed_uuid);
702702
} else {
703703
// Send result message to anyone that asked
704-
shared_this->publish_result(goal_uuid, result_message);
704+
shared_this->publish_result(goal_uuid, result_message);
705705
// Publish a status message any time a goal handle changes state
706-
shared_this->publish_status();
706+
shared_this->publish_status();
707707
}
708708

709709
// notify base so it can recalculate the expired goal timer
@@ -746,7 +746,7 @@ class Server : public ServerBase, public std::enable_shared_from_this<Server<Act
746746
std::move(status_msg));
747747

748748
} else {
749-
shared_this->publish_status();
749+
shared_this->publish_status();
750750
}
751751
};
752752

@@ -780,7 +780,7 @@ class Server : public ServerBase, public std::enable_shared_from_this<Server<Act
780780
ipc_action_client_id,
781781
std::move(feedback_msg));
782782
} else {
783-
shared_this->publish_feedback(std::static_pointer_cast<void>(feedback_msg));
783+
shared_this->publish_feedback(std::static_pointer_cast<void>(feedback_msg));
784784
}
785785
};
786786

0 commit comments

Comments
 (0)