Skip to content

Commit 0d6d9e6

Browse files
Deprecate method names that use CamelCase in rclcpp_components (#1716)
* Rename methods in ComponentManager to use snake_case Signed-off-by: Rebecca Butler <[email protected]> * Deprecate old method names Signed-off-by: Rebecca Butler <[email protected]>
1 parent 86c079d commit 0d6d9e6

File tree

2 files changed

+60
-18
lines changed

2 files changed

+60
-18
lines changed

rclcpp_components/include/rclcpp_components/component_manager.hpp

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class ComponentManager : public rclcpp::Node
109109
virtual ~ComponentManager();
110110

111111
/// Return a list of valid loadable components in a given package.
112-
/*
112+
/**
113113
* \param package_name name of the package
114114
* \param resource_index name of the executable
115115
* \throws ComponentManagerException if the resource was not found or a invalid resource entry
@@ -122,7 +122,7 @@ class ComponentManager : public rclcpp::Node
122122
const std::string & resource_index = "rclcpp_components") const;
123123

124124
/// Instantiate a component from a dynamic library.
125-
/*
125+
/**
126126
* \param resource a component resource (class name + library path)
127127
* \return a NodeFactory interface
128128
*/
@@ -132,16 +132,16 @@ class ComponentManager : public rclcpp::Node
132132

133133
protected:
134134
/// Create node options for loaded component
135-
/*
135+
/**
136136
* \param request information with the node to load
137137
* \return node options
138138
*/
139139
RCLCPP_COMPONENTS_PUBLIC
140140
virtual rclcpp::NodeOptions
141-
CreateNodeOptions(const std::shared_ptr<LoadNode::Request> request);
141+
create_node_options(const std::shared_ptr<LoadNode::Request> request);
142142

143143
/// Service callback to load a new node in the component
144-
/*
144+
/**
145145
* This function allows to add parameters, remap rules, a specific node, name a namespace
146146
* and/or additional arguments.
147147
*
@@ -155,27 +155,55 @@ class ComponentManager : public rclcpp::Node
155155
*/
156156
RCLCPP_COMPONENTS_PUBLIC
157157
virtual void
158-
OnLoadNode(
158+
on_load_node(
159159
const std::shared_ptr<rmw_request_id_t> request_header,
160160
const std::shared_ptr<LoadNode::Request> request,
161161
std::shared_ptr<LoadNode::Response> response);
162162

163+
/**
164+
* \deprecated Use on_load_node() instead
165+
*/
166+
[[deprecated("Use on_load_node() instead")]]
167+
RCLCPP_COMPONENTS_PUBLIC
168+
virtual void
169+
OnLoadNode(
170+
const std::shared_ptr<rmw_request_id_t> request_header,
171+
const std::shared_ptr<LoadNode::Request> request,
172+
std::shared_ptr<LoadNode::Response> response)
173+
{
174+
on_load_node(request_header, request, response);
175+
}
176+
163177
/// Service callback to unload a node in the component
164-
/*
178+
/**
165179
* \param request_header unused
166180
* \param request unique identifier to remove from the component
167181
* \param response true on the success field if the node unload was succefully, otherwise false
168182
* and the error_message field contains the error.
169183
*/
170184
RCLCPP_COMPONENTS_PUBLIC
171185
virtual void
172-
OnUnloadNode(
186+
on_unload_node(
173187
const std::shared_ptr<rmw_request_id_t> request_header,
174188
const std::shared_ptr<UnloadNode::Request> request,
175189
std::shared_ptr<UnloadNode::Response> response);
176190

191+
/**
192+
* \deprecated Use on_unload_node() instead
193+
*/
194+
[[deprecated("Use on_unload_node() instead")]]
195+
RCLCPP_COMPONENTS_PUBLIC
196+
virtual void
197+
OnUnloadNode(
198+
const std::shared_ptr<rmw_request_id_t> request_header,
199+
const std::shared_ptr<UnloadNode::Request> request,
200+
std::shared_ptr<UnloadNode::Response> response)
201+
{
202+
on_unload_node(request_header, request, response);
203+
}
204+
177205
/// Service callback to get the list of nodes in the component
178-
/*
206+
/**
179207
* Return a two list: one with the unique identifiers and other with full name of the nodes.
180208
*
181209
* \param request_header unused
@@ -184,11 +212,25 @@ class ComponentManager : public rclcpp::Node
184212
*/
185213
RCLCPP_COMPONENTS_PUBLIC
186214
virtual void
187-
OnListNodes(
215+
on_list_nodes(
188216
const std::shared_ptr<rmw_request_id_t> request_header,
189217
const std::shared_ptr<ListNodes::Request> request,
190218
std::shared_ptr<ListNodes::Response> response);
191219

220+
/**
221+
* \deprecated Use on_list_nodes() instead
222+
*/
223+
[[deprecated("Use on_list_nodes() instead")]]
224+
RCLCPP_COMPONENTS_PUBLIC
225+
virtual void
226+
OnListNodes(
227+
const std::shared_ptr<rmw_request_id_t> request_header,
228+
const std::shared_ptr<ListNodes::Request> request,
229+
std::shared_ptr<ListNodes::Response> response)
230+
{
231+
on_list_nodes(request_header, request, response);
232+
}
233+
192234
private:
193235
std::weak_ptr<rclcpp::Executor> executor_;
194236

rclcpp_components/src/component_manager.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ ComponentManager::ComponentManager(
3939
{
4040
loadNode_srv_ = create_service<LoadNode>(
4141
"~/_container/load_node",
42-
std::bind(&ComponentManager::OnLoadNode, this, _1, _2, _3));
42+
std::bind(&ComponentManager::on_load_node, this, _1, _2, _3));
4343
unloadNode_srv_ = create_service<UnloadNode>(
4444
"~/_container/unload_node",
45-
std::bind(&ComponentManager::OnUnloadNode, this, _1, _2, _3));
45+
std::bind(&ComponentManager::on_unload_node, this, _1, _2, _3));
4646
listNodes_srv_ = create_service<ListNodes>(
4747
"~/_container/list_nodes",
48-
std::bind(&ComponentManager::OnListNodes, this, _1, _2, _3));
48+
std::bind(&ComponentManager::on_list_nodes, this, _1, _2, _3));
4949
}
5050

5151
ComponentManager::~ComponentManager()
@@ -122,7 +122,7 @@ ComponentManager::create_component_factory(const ComponentResource & resource)
122122
}
123123

124124
rclcpp::NodeOptions
125-
ComponentManager::CreateNodeOptions(const std::shared_ptr<LoadNode::Request> request)
125+
ComponentManager::create_node_options(const std::shared_ptr<LoadNode::Request> request)
126126
{
127127
std::vector<rclcpp::Parameter> parameters;
128128
for (const auto & p : request->parameters) {
@@ -167,7 +167,7 @@ ComponentManager::CreateNodeOptions(const std::shared_ptr<LoadNode::Request> req
167167
}
168168

169169
void
170-
ComponentManager::OnLoadNode(
170+
ComponentManager::on_load_node(
171171
const std::shared_ptr<rmw_request_id_t> request_header,
172172
const std::shared_ptr<LoadNode::Request> request,
173173
std::shared_ptr<LoadNode::Response> response)
@@ -187,7 +187,7 @@ ComponentManager::OnLoadNode(
187187
continue;
188188
}
189189

190-
auto options = CreateNodeOptions(request);
190+
auto options = create_node_options(request);
191191
auto node_id = unique_id_++;
192192

193193
if (0 == node_id) {
@@ -237,7 +237,7 @@ ComponentManager::OnLoadNode(
237237
}
238238

239239
void
240-
ComponentManager::OnUnloadNode(
240+
ComponentManager::on_unload_node(
241241
const std::shared_ptr<rmw_request_id_t> request_header,
242242
const std::shared_ptr<UnloadNode::Request> request,
243243
std::shared_ptr<UnloadNode::Response> response)
@@ -262,7 +262,7 @@ ComponentManager::OnUnloadNode(
262262
}
263263

264264
void
265-
ComponentManager::OnListNodes(
265+
ComponentManager::on_list_nodes(
266266
const std::shared_ptr<rmw_request_id_t> request_header,
267267
const std::shared_ptr<ListNodes::Request> request,
268268
std::shared_ptr<ListNodes::Response> response)

0 commit comments

Comments
 (0)