{"action":"created","comment":{"url":"https://api.github.com/repos/ros2/rclcpp/pulls/comments/29301936","id":29301936,"diff_hunk":"@@ -0,0 +1,225 @@\n+// Copyright 2014 Open Source Robotics Foundation, Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+#ifndef RCLCPP_RCLCPP_PARAMETER_HPP_\n+#define RCLCPP_RCLCPP_PARAMETER_HPP_\n+\n+#include <string>\n+\n+#include <rmw/rmw.h>\n+\n+#include <rclcpp/macros.hpp>\n+#include <rclcpp/node.hpp>\n+\n+#include <rcl_interfaces/GetParameters.h>\n+#include <rcl_interfaces/GetParameterTypes.h>\n+#include <rcl_interfaces/Parameter.h>\n+#include <rcl_interfaces/ParameterDescriptor.h>\n+#include <rcl_interfaces/ParameterType.h>\n+#include <rcl_interfaces/SetParameters.h>\n+#include <rcl_interfaces/SetParametersAtomically.h>\n+#include <rcl_interfaces/ListParameters.h>\n+#include <rcl_interfaces/DescribeParameters.h>\n+\n+namespace rclcpp\n+{\n+\n+namespace parameter\n+{\n+\n+// Structure to store an arbitrary parameter with templated get/set methods\n+class ParameterVariant\n+{\n+public:\n+  ParameterVariant()\n+  : name_(\"\")\n+  {\n+    value_.parameter_type = rcl_interfaces::ParameterType::PARAMETER_NOT_SET;\n+  }\n+  ParameterVariant(const std::string & name, const bool bool_value)\n+  : name_(name)\n+  {\n+    value_.bool_value = bool_value;\n+    value_.parameter_type = rcl_interfaces::ParameterType::PARAMETER_BOOL;\n+  }\n+  ParameterVariant(const std::string & name, const int64_t int_value)\n+  : name_(name)\n+  {\n+    value_.integer_value = int_value;\n+    value_.parameter_type = rcl_interfaces::ParameterType::PARAMETER_INTEGER;\n+  }\n+  ParameterVariant(const std::string & name, const double double_value)\n+  : name_(name)\n+  {\n+    value_.double_value = double_value;\n+    value_.parameter_type = rcl_interfaces::ParameterType::PARAMETER_DOUBLE;\n+  }\n+  ParameterVariant(const std::string & name, const std::string & string_value)\n+  : name_(name)\n+  {\n+    value_.string_value = string_value;\n+    value_.parameter_type = rcl_interfaces::ParameterType::PARAMETER_STRING;\n+  }\n+\n+  /* Templated getter */\n+  template<typename T>\n+  T\n+  get_value() const;\n+\n+  inline uint8_t get_typeID() const {return value_.parameter_type; }\n+\n+  inline std::string get_name() const {return name_; }\n+\n+  inline rcl_interfaces::ParameterValue get_parameter_value()\n+  {\n+    return value_;\n+  }\n+\n+private:\n+  std::string name_;\n+  rcl_interfaces::ParameterValue value_;\n+};\n+\n+template<>\n+inline int64_t ParameterVariant::get_value() const\n+{\n+  if (value_.parameter_type != rcl_interfaces::ParameterType::PARAMETER_INTEGER) {\n+    // TODO: use custom exception\n+    throw std::runtime_error(\"Invalid type\");\n+  }\n+  return value_.integer_value;\n+}\n+template<>\n+inline double ParameterVariant::get_value() const\n+{\n+  if (value_.parameter_type != rcl_interfaces::ParameterType::PARAMETER_DOUBLE) {\n+    // TODO: use custom exception\n+    throw std::runtime_error(\"Invalid type\");\n+  }\n+  return value_.double_value;\n+}\n+template<>\n+inline std::string ParameterVariant::get_value() const\n+{\n+  if (value_.parameter_type != rcl_interfaces::ParameterType::PARAMETER_STRING) {\n+    // TODO: use custom exception\n+    throw std::runtime_error(\"Invalid type\");\n+  }\n+  return value_.string_value;\n+}\n+template<>\n+inline bool ParameterVariant::get_value() const\n+{\n+  if (value_.parameter_type != rcl_interfaces::ParameterType::PARAMETER_BOOL) {\n+    // TODO: use custom exception\n+    throw std::runtime_error(\"Invalid type\");\n+  }\n+  return value_.bool_value;\n+}\n+\n+enum ParameterType {","path":"rclcpp/include/rclcpp/parameter.hpp","position":131,"original_position":131,"commit_id":"bdcb4289f57e109ea8c3b585bd657ecadbe48d4c","original_commit_id":"bdcb4289f57e109ea8c3b585bd657ecadbe48d4c","user":{"login":"tfoote","id":447804,"avatar_url":"https://avatars.githubusercontent.com/u/447804?v=3","gravatar_id":"","url":"https://api.github.com/users/tfoote","html_url":"https://github.com/tfoote","followers_url":"https://api.github.com/users/tfoote/followers","following_url":"https://api.github.com/users/tfoote/following{/other_user}","gists_url":"https://api.github.com/users/tfoote/gists{/gist_id}","starred_url":"https://api.github.com/users/tfoote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfoote/subscriptions","organizations_url":"https://api.github.com/users/tfoote/orgs","repos_url":"https://api.github.com/users/tfoote/repos","events_url":"https://api.github.com/users/tfoote/events{/privacy}","received_events_url":"https://api.github.com/users/tfoote/received_events","type":"User","site_admin":false},"body":"We can `#include <rcl_interfaces/ParameterTypes.h>` and then use the constants from the msg file. I think they'll be `rcl_interfaces::ParameterTypes::PARAMETER_NOT_SET` as the enums. This will make sure they're always consistent. ","created_at":"2015-04-29T00:22:54Z","updated_at":"2015-04-29T00:22:54Z","html_url":"https://github.com/ros2/rclcpp/pull/26#discussion_r29301936","pull_request_url":"https://api.github.com/repos/ros2/rclcpp/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/comments/29301936"},"html":{"href":"https://github.com/ros2/rclcpp/pull/26#discussion_r29301936"},"pull_request":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/ros2/rclcpp/pulls/26","id":34321023,"html_url":"https://github.com/ros2/rclcpp/pull/26","diff_url":"https://github.com/ros2/rclcpp/pull/26.diff","patch_url":"https://github.com/ros2/rclcpp/pull/26.patch","issue_url":"https://api.github.com/repos/ros2/rclcpp/issues/26","number":26,"state":"open","locked":false,"title":"Skeleton parameters async API","user":{"login":"esteve","id":33620,"avatar_url":"https://avatars.githubusercontent.com/u/33620?v=3","gravatar_id":"","url":"https://api.github.com/users/esteve","html_url":"https://github.com/esteve","followers_url":"https://api.github.com/users/esteve/followers","following_url":"https://api.github.com/users/esteve/following{/other_user}","gists_url":"https://api.github.com/users/esteve/gists{/gist_id}","starred_url":"https://api.github.com/users/esteve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esteve/subscriptions","organizations_url":"https://api.github.com/users/esteve/orgs","repos_url":"https://api.github.com/users/esteve/repos","events_url":"https://api.github.com/users/esteve/events{/privacy}","received_events_url":"https://api.github.com/users/esteve/received_events","type":"User","site_admin":false},"body":"Connects to ros2/ros2#28\r\n\r\n@dirk-thomas @tfoote @wjwwood ","created_at":"2015-04-28T23:14:58Z","updated_at":"2015-04-29T00:22:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39e5e2889f6b0f20d5b2a5d929e26617f9b5b433","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ros2/rclcpp/pulls/26/commits","review_comments_url":"https://api.github.com/repos/ros2/rclcpp/pulls/26/comments","review_comment_url":"https://api.github.com/repos/ros2/rclcpp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ros2/rclcpp/issues/26/comments","statuses_url":"https://api.github.com/repos/ros2/rclcpp/statuses/bdcb4289f57e109ea8c3b585bd657ecadbe48d4c","head":{"label":"ros2:parameters-api-review","ref":"parameters-api-review","sha":"bdcb4289f57e109ea8c3b585bd657ecadbe48d4c","user":{"login":"ros2","id":3979232,"avatar_url":"https://avatars.githubusercontent.com/u/3979232?v=3","gravatar_id":"","url":"https://api.github.com/users/ros2","html_url":"https://github.com/ros2","followers_url":"https://api.github.com/users/ros2/followers","following_url":"https://api.github.com/users/ros2/following{/other_user}","gists_url":"https://api.github.com/users/ros2/gists{/gist_id}","starred_url":"https://api.github.com/users/ros2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros2/subscriptions","organizations_url":"https://api.github.com/users/ros2/orgs","repos_url":"https://api.github.com/users/ros2/repos","events_url":"https://api.github.com/users/ros2/events{/privacy}","received_events_url":"https://api.github.com/users/ros2/received_events","type":"Organization","site_admin":false},"repo":{"id":22737333,"name":"rclcpp","full_name":"ros2/rclcpp","owner":{"login":"ros2","id":3979232,"avatar_url":"https://avatars.githubusercontent.com/u/3979232?v=3","gravatar_id":"","url":"https://api.github.com/users/ros2","html_url":"https://github.com/ros2","followers_url":"https://api.github.com/users/ros2/followers","following_url":"https://api.github.com/users/ros2/following{/other_user}","gists_url":"https://api.github.com/users/ros2/gists{/gist_id}","starred_url":"https://api.github.com/users/ros2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros2/subscriptions","organizations_url":"https://api.github.com/users/ros2/orgs","repos_url":"https://api.github.com/users/ros2/repos","events_url":"https://api.github.com/users/ros2/events{/privacy}","received_events_url":"https://api.github.com/users/ros2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ros2/rclcpp","description":"rclcpp (ROS Client Library for C++)","fork":false,"url":"https://api.github.com/repos/ros2/rclcpp","forks_url":"https://api.github.com/repos/ros2/rclcpp/forks","keys_url":"https://api.github.com/repos/ros2/rclcpp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ros2/rclcpp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ros2/rclcpp/teams","hooks_url":"https://api.github.com/repos/ros2/rclcpp/hooks","issue_events_url":"https://api.github.com/repos/ros2/rclcpp/issues/events{/number}","events_url":"https://api.github.com/repos/ros2/rclcpp/events","assignees_url":"https://api.github.com/repos/ros2/rclcpp/assignees{/user}","branches_url":"https://api.github.com/repos/ros2/rclcpp/branches{/branch}","tags_url":"https://api.github.com/repos/ros2/rclcpp/tags","blobs_url":"https://api.github.com/repos/ros2/rclcpp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ros2/rclcpp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ros2/rclcpp/git/refs{/sha}","trees_url":"https://api.github.com/repos/ros2/rclcpp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ros2/rclcpp/statuses/{sha}","languages_url":"https://api.github.com/repos/ros2/rclcpp/languages","stargazers_url":"https://api.github.com/repos/ros2/rclcpp/stargazers","contributors_url":"https://api.github.com/repos/ros2/rclcpp/contributors","subscribers_url":"https://api.github.com/repos/ros2/rclcpp/subscribers","subscription_url":"https://api.github.com/repos/ros2/rclcpp/subscription","commits_url":"https://api.github.com/repos/ros2/rclcpp/commits{/sha}","git_commits_url":"https://api.github.com/repos/ros2/rclcpp/git/commits{/sha}","comments_url":"https://api.github.com/repos/ros2/rclcpp/comments{/number}","issue_comment_url":"https://api.github.com/repos/ros2/rclcpp/issues/comments{/number}","contents_url":"https://api.github.com/repos/ros2/rclcpp/contents/{+path}","compare_url":"https://api.github.com/repos/ros2/rclcpp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ros2/rclcpp/merges","archive_url":"https://api.github.com/repos/ros2/rclcpp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ros2/rclcpp/downloads","issues_url":"https://api.github.com/repos/ros2/rclcpp/issues{/number}","pulls_url":"https://api.github.com/repos/ros2/rclcpp/pulls{/number}","milestones_url":"https://api.github.com/repos/ros2/rclcpp/milestones{/number}","notifications_url":"https://api.github.com/repos/ros2/rclcpp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ros2/rclcpp/labels{/name}","releases_url":"https://api.github.com/repos/ros2/rclcpp/releases{/id}","created_at":"2014-08-07T21:36:38Z","updated_at":"2015-04-28T22:09:23Z","pushed_at":"2015-04-28T23:37:40Z","git_url":"git://github.com/ros2/rclcpp.git","ssh_url":"git@github.com:ros2/rclcpp.git","clone_url":"https://github.com/ros2/rclcpp.git","svn_url":"https://github.com/ros2/rclcpp","homepage":"","size":904,"stargazers_count":5,"watchers_count":5,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":5,"default_branch":"master"}},"base":{"label":"ros2:master","ref":"master","sha":"8ad1f1f4c5b1ab5b152cc664c56f3c991eaaac4f","user":{"login":"ros2","id":3979232,"avatar_url":"https://avatars.githubusercontent.com/u/3979232?v=3","gravatar_id":"","url":"https://api.github.com/users/ros2","html_url":"https://github.com/ros2","followers_url":"https://api.github.com/users/ros2/followers","following_url":"https://api.github.com/users/ros2/following{/other_user}","gists_url":"https://api.github.com/users/ros2/gists{/gist_id}","starred_url":"https://api.github.com/users/ros2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros2/subscriptions","organizations_url":"https://api.github.com/users/ros2/orgs","repos_url":"https://api.github.com/users/ros2/repos","events_url":"https://api.github.com/users/ros2/events{/privacy}","received_events_url":"https://api.github.com/users/ros2/received_events","type":"Organization","site_admin":false},"repo":{"id":22737333,"name":"rclcpp","full_name":"ros2/rclcpp","owner":{"login":"ros2","id":3979232,"avatar_url":"https://avatars.githubusercontent.com/u/3979232?v=3","gravatar_id":"","url":"https://api.github.com/users/ros2","html_url":"https://github.com/ros2","followers_url":"https://api.github.com/users/ros2/followers","following_url":"https://api.github.com/users/ros2/following{/other_user}","gists_url":"https://api.github.com/users/ros2/gists{/gist_id}","starred_url":"https://api.github.com/users/ros2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros2/subscriptions","organizations_url":"https://api.github.com/users/ros2/orgs","repos_url":"https://api.github.com/users/ros2/repos","events_url":"https://api.github.com/users/ros2/events{/privacy}","received_events_url":"https://api.github.com/users/ros2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ros2/rclcpp","description":"rclcpp (ROS Client Library for C++)","fork":false,"url":"https://api.github.com/repos/ros2/rclcpp","forks_url":"https://api.github.com/repos/ros2/rclcpp/forks","keys_url":"https://api.github.com/repos/ros2/rclcpp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ros2/rclcpp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ros2/rclcpp/teams","hooks_url":"https://api.github.com/repos/ros2/rclcpp/hooks","issue_events_url":"https://api.github.com/repos/ros2/rclcpp/issues/events{/number}","events_url":"https://api.github.com/repos/ros2/rclcpp/events","assignees_url":"https://api.github.com/repos/ros2/rclcpp/assignees{/user}","branches_url":"https://api.github.com/repos/ros2/rclcpp/branches{/branch}","tags_url":"https://api.github.com/repos/ros2/rclcpp/tags","blobs_url":"https://api.github.com/repos/ros2/rclcpp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ros2/rclcpp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ros2/rclcpp/git/refs{/sha}","trees_url":"https://api.github.com/repos/ros2/rclcpp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ros2/rclcpp/statuses/{sha}","languages_url":"https://api.github.com/repos/ros2/rclcpp/languages","stargazers_url":"https://api.github.com/repos/ros2/rclcpp/stargazers","contributors_url":"https://api.github.com/repos/ros2/rclcpp/contributors","subscribers_url":"https://api.github.com/repos/ros2/rclcpp/subscribers","subscription_url":"https://api.github.com/repos/ros2/rclcpp/subscription","commits_url":"https://api.github.com/repos/ros2/rclcpp/commits{/sha}","git_commits_url":"https://api.github.com/repos/ros2/rclcpp/git/commits{/sha}","comments_url":"https://api.github.com/repos/ros2/rclcpp/comments{/number}","issue_comment_url":"https://api.github.com/repos/ros2/rclcpp/issues/comments{/number}","contents_url":"https://api.github.com/repos/ros2/rclcpp/contents/{+path}","compare_url":"https://api.github.com/repos/ros2/rclcpp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ros2/rclcpp/merges","archive_url":"https://api.github.com/repos/ros2/rclcpp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ros2/rclcpp/downloads","issues_url":"https://api.github.com/repos/ros2/rclcpp/issues{/number}","pulls_url":"https://api.github.com/repos/ros2/rclcpp/pulls{/number}","milestones_url":"https://api.github.com/repos/ros2/rclcpp/milestones{/number}","notifications_url":"https://api.github.com/repos/ros2/rclcpp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ros2/rclcpp/labels{/name}","releases_url":"https://api.github.com/repos/ros2/rclcpp/releases{/id}","created_at":"2014-08-07T21:36:38Z","updated_at":"2015-04-28T22:09:23Z","pushed_at":"2015-04-28T23:37:40Z","git_url":"git://github.com/ros2/rclcpp.git","ssh_url":"git@github.com:ros2/rclcpp.git","clone_url":"https://github.com/ros2/rclcpp.git","svn_url":"https://github.com/ros2/rclcpp","homepage":"","size":904,"stargazers_count":5,"watchers_count":5,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/26"},"html":{"href":"https://github.com/ros2/rclcpp/pull/26"},"issue":{"href":"https://api.github.com/repos/ros2/rclcpp/issues/26"},"comments":{"href":"https://api.github.com/repos/ros2/rclcpp/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/ros2/rclcpp/statuses/bdcb4289f57e109ea8c3b585bd657ecadbe48d4c"}}}}