ros1_node_parameter_reader.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
17 #include <ros/ros.h>
18 
19 namespace Aws {
20 namespace Client {
21 
22 constexpr char kParameterNsSeparator = '/';
23 constexpr char kNodeNsSeparator = '/';
24 
25 
26 template <class T>
27 static AwsError ReadParamTemplate(const ParameterPath & param_path, T & out)
28 {
29  std::string name = param_path.get_resolved_path(kNodeNsSeparator, kParameterNsSeparator);
30  std::string key;
31  if (ros::param::search(name, key) && ros::param::get(key, out)) {
32  return AWS_ERR_OK;
33  }
34  return AWS_ERR_NOT_FOUND;
35 }
36 
37 AwsError Ros1NodeParameterReader::ReadParam(const ParameterPath & param_path, std::vector<std::string> & out) const
38 {
39  return ReadParamTemplate(param_path, out);
40 }
41 
42 AwsError Ros1NodeParameterReader::ReadParam(const ParameterPath & param_path, double & out) const
43 {
44  return ReadParamTemplate(param_path, out);
45 }
46 
47 AwsError Ros1NodeParameterReader::ReadParam(const ParameterPath & param_path, int & out) const
48 {
49  return ReadParamTemplate(param_path, out);
50 }
51 
52 AwsError Ros1NodeParameterReader::ReadParam(const ParameterPath & param_path, bool & out) const
53 {
54  return ReadParamTemplate(param_path, out);
55 }
56 
57 AwsError Ros1NodeParameterReader::ReadParam(const ParameterPath & param_path, std::string & out) const
58 {
59  return ReadParamTemplate(param_path, out);
60 }
61 
62 AwsError Ros1NodeParameterReader::ReadParam(const ParameterPath & param_path, Aws::String & out) const
63 {
64  std::string value;
65  AwsError result = ReadParam(param_path, value);
66  if (result == AWS_ERR_OK) {
67  out = Aws::String(value.c_str()); // NOLINT(readability-redundant-string-cstr)
68  }
69  return result;
70 }
71 
73  std::map<std::string, std::string> & out) const
74 {
75  return ReadParamTemplate(param_path, out);
76 }
77 
78 } // namespace Client
79 } // namespace Aws
constexpr char kNodeNsSeparator
AwsError ReadParam(const ParameterPath &param_path, std::vector< std::string > &out) const override
ROSCPP_DECL bool get(const std::string &key, std::string &s)
std::string get_resolved_path(char node_namespace_separator, char parameter_namespace_separator) const
AWS_ERR_NOT_FOUND
ROSCPP_DECL bool search(const std::string &ns, const std::string &key, std::string &result)
AWS_ERR_OK
static AwsError ReadParamTemplate(const ParameterPath &param_path, T &out)
constexpr char kParameterNsSeparator


aws_ros1_common
Author(s): AWS RoboMaker
autogenerated on Thu Mar 4 2021 03:25:44