2020namespace Aws {
2121namespace Client {
2222
23- class ParameterPath {
24- public:
25- /* *
26- * Legacy constructor for backwards compatibility.
27- * @hint For ROS1, the node namespace separator is the same as the parameter namespace separator,
28- * and so the path would simply be the given string (dictated by Ros1NodeParameterReader).
29- * For ROS2 the separators differ; If only node namespace separators were found, we would treat them as parameter separators.
30- * @param name Parameter name, which in practice would be the path of the parameter, e.g. config/timeoutMs.
31- */
32- ParameterPath (const char * name) : name_(name) {}
33-
34- /* *
35- * @example The parameter under node "lidar_node" in namespace "sensor_nodes",
36- * with parameter namespace "settings" and parameter key "frequency", should be specified as follows:
37- * node_namespace: ["sensor_nodes", "lidar_node"]
38- * parameter_path_keys: ["settings", "frequency"]
39- * @note Node namespaces should be empty if used by a node looking for a parameter of its own (a local parameter).
40- * @param node_namespaces
41- * @param parameter_path_keys
42- */
43- ParameterPath (const std::vector<std::string> & node_namespaces, const std::vector<std::string> & parameter_path_keys) :
44- node_namespaces_ (node_namespaces), parameter_path_keys_(parameter_path_keys) {}
45-
46- /* *
47- * @example The local parameter "timeout" in parameter namespace "config" should be specified as follows:
48- * ParameterPath("config", "timeout")
49- * @tparam Args
50- * @param parameter_path_keys
51- */
52- template <typename ...Args>
53- ParameterPath (Args... parameter_path_keys) :
54- parameter_path_keys_ (std::vector<std::string>{(parameter_path_keys)...}) {}
55-
56- /* *
57- * @note Only applies if node_namespaces was specified during construction; otherwise, an empty string is returned.
58- * @param node_namespace_separator
59- * @return string The parameter's whereabouts in the node namespace hierarchy.
60- */
61- std::string get_node_path (char node_namespace_separator) const
62- {
63- std::string resolved_path;
64- /* Construct the node's path by the provided lists of keys */
65- for (auto key = node_namespaces_.begin (); key != node_namespaces_.end (); key++) {
66- resolved_path += *key + node_namespace_separator;
67- }
68- if (!resolved_path.empty () && resolved_path.back () == node_namespace_separator) {
69- resolved_path.pop_back ();
70- }
71- return resolved_path;
72- }
73- /* *
74- * @note Only applies if parameter_path_keys was specified during construction; otherwise, an empty string is returned.
75- * @param parameter_namespace_separator
76- * @return string The parameter path including parameter namespaces but excluding node's namespaces.
77- */
78- std::string get_local_path (char parameter_namespace_separator) const
79- {
80- std::string resolved_path;
81- /* Construct the parameter's path by the provided lists of keys */
82- for (auto key = parameter_path_keys_.begin (); key != parameter_path_keys_.end (); key++) {
83- resolved_path += *key + parameter_namespace_separator;
84- }
85- if (!resolved_path.empty () && resolved_path.back () == parameter_namespace_separator) {
86- resolved_path.pop_back ();
87- }
88- return resolved_path;
89- }
90- /* *
91- * Resolves & returns the parameter's path. Supports two separate use cases:
92- * 1. A single, 'flat' string was provided upon construction.
93- * In this case, we return it as is.
94- * 2. Detailed lists of strings were specified for the parameter & node namespaces.
95- * In this case, we construct the resolved path using the provided separators.
96- * @param node_namespace_separator
97- * @param parameter_namespace_separator
98- * @return string representing the full, resolved path of the parameter.
99- * @note If node_namespaces and parameter_path_keys are empty, an empty string would be returned.
100- */
101- std::string get_resolved_path (char node_namespace_separator,
102- char parameter_namespace_separator) const
103- {
104- if (!name_.empty ()) {
105- return name_;
106- } else {
107- std::string resolved_path = get_node_path (node_namespace_separator);
108- if (!resolved_path.empty ()) {
109- resolved_path += node_namespace_separator;
110- }
111- resolved_path += get_local_path (parameter_namespace_separator);
112- return resolved_path;
113- }
114- }
115- private:
116- /* *
117- * Member variables to store the parameter's path in the namespace hierarchy.
118- * parameter_path_keys_ Parameter namespaces list.
119- * node_namespaces_ Node namespaces list.
120- * name_ A single string. Used when simpler initialization is required, instead of the aforementioned namespace lists.
121- */
122- const std::vector<std::string> parameter_path_keys_;
123- const std::vector<std::string> node_namespaces_;
124- const std::string name_;
125- };
126-
12723class ParameterReaderInterface
12824{
12925public:
@@ -132,65 +28,58 @@ class ParameterReaderInterface
13228 /* *
13329 * read a list from the provided parameter name
13430 * @param name the name of the parameter to be read
135- * @param out the output of 'double' type.
31+ * @param out the output of 'double' type
13632 * @return AWS_ERR_OK if read was successful, AWS_ERR_NOT_FOUND if the parameter was not found
137- * @note if the return code is not AWS_ERR_OK, out remains unchanged.
13833 */
139- virtual AwsError ReadList (const ParameterPath & parameter_path , std::vector<std::string> & out) const = 0;
34+ virtual AwsError ReadList (const char * name , std::vector<std::string> & out) const = 0;
14035
14136 /* *
14237 * read a double value from the provided parameter name
143- * @param parameter_path an object representing the path of the parameter to be read
38+ * @param name the name of the parameter to be read
14439 * @param out the output of 'double' type
14540 * @return AWS_ERR_OK if read was successful, AWS_ERR_NOT_FOUND if the parameter was not found
146- * @note if the return code is not AWS_ERR_OK, out remains unchanged.
14741 */
148- virtual AwsError ReadDouble (const ParameterPath & parameter_path , double & out) const = 0;
42+ virtual AwsError ReadDouble (const char * name , double & out) const = 0;
14943
15044 /* *
15145 * read an integer value from the provided parameter name
152- * @param parameter_path an object representing the path of the parameter to be read
46+ * @param name the name of the parameter to be read
15347 * @param out the output of 'int' type
15448 * @return AWS_ERR_OK if read was successful, AWS_ERR_NOT_FOUND if the parameter was not found
155- * @note if the return code is not AWS_ERR_OK, out remains unchanged.
15649 */
157- virtual AwsError ReadInt (const ParameterPath & parameter_path , int & out) const = 0;
50+ virtual AwsError ReadInt (const char * name , int & out) const = 0;
15851
15952 /* *
16053 * read a boolean value from the provided parameter name
161- * @param parameter_path an object representing the path of the parameter to be read
54+ * @param name the name of the parameter to be read
16255 * @param out the output of 'bool' type
16356 * @return AWS_ERR_OK if read was successful, AWS_ERR_NOT_FOUND if the parameter was not found
164- * @note if the return code is not AWS_ERR_OK, out remains unchanged.
16557 */
166- virtual AwsError ReadBool (const ParameterPath & parameter_path , bool & out) const = 0;
58+ virtual AwsError ReadBool (const char * name , bool & out) const = 0;
16759
16860 /* *
16961 * read a string value from the provided parameter name
170- * @param parameter_path an object representing the path of the parameter to be read
62+ * @param name the name of the parameter to be read
17163 * @param out the output of 'Aws::String' type
17264 * @return AWS_ERR_OK if read was successful, AWS_ERR_NOT_FOUND if the parameter was not found
173- * @note if the return code is not AWS_ERR_OK, out remains unchanged.
17465 */
175- virtual AwsError ReadString (const ParameterPath & parameter_path , Aws::String & out) const = 0;
66+ virtual AwsError ReadString (const char * name , Aws::String & out) const = 0;
17667
17768 /* *
17869 * read a string from the provided parameter name
179- * @param parameter_path an object representing the path of the parameter to be read
70+ * @param name the name of the parameter to be read
18071 * @param out the output of 'std::string' type
18172 * @return AWS_ERR_OK if read was successful, AWS_ERR_NOT_FOUND if the parameter was not found
182- * @note if the return code is not AWS_ERR_OK, out remains unchanged.
18373 */
184- virtual AwsError ReadStdString (const ParameterPath & parameter_path , std::string & out) const = 0;
74+ virtual AwsError ReadStdString (const char * name , std::string & out) const = 0;
18575
18676 /* *
18777 * read a map from the provided parameter name
188- * @param parameter_path an object representing the path of the parameter to be read
78+ * @param name the name of the parameter to be read
18979 * @param out the output of 'std::map' type
19080 * @return AWS_ERR_OK if read was successful, AWS_ERR_NOT_FOUND if the parameter was not found
191- * @note if the return code is not AWS_ERR_OK, out remains unchanged.
19281 */
193- virtual AwsError ReadMap (const ParameterPath & parameter_path , std::map<std::string, std::string> & out) const = 0;
82+ virtual AwsError ReadMap (const char * name , std::map<std::string, std::string> & out) const = 0;
19483};
19584
19685} // namespace Client
0 commit comments