{"action":"created","comment":{"url":"https://api.github.com/repos/ros2/rclcpp/pulls/comments/89942011","pull_request_review_id":10469424,"id":89942011,"diff_hunk":"@@ -0,0 +1,133 @@\n+// Copyright 2016 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+#include <gtest/gtest.h>\n+\n+#include <string>\n+#include <memory>\n+\n+#include \"rclcpp/node.hpp\"\n+#include \"rclcpp/any_service_callback.hpp\"\n+#include \"rclcpp/service.hpp\"\n+#include \"rclcpp/rclcpp.hpp\"\n+\n+#include \"rcl/service.h\"\n+\n+#include \"rclcpp/srv/mock.hpp\"\n+#include \"rclcpp/srv/mock.h\"\n+\n+class TestExternallyDefinedServices : public ::testing::Test\n+{\n+protected:\n+  static void SetUpTestCase()\n+  {\n+    rclcpp::init(0, nullptr);\n+  }\n+};\n+\n+void\n+callback(const std::shared_ptr<rclcpp::srv::Mock::Request>/*req*/,\n+  std::shared_ptr<rclcpp::srv::Mock::Response>/*resp*/)\n+{}\n+\n+TEST_F(TestExternallyDefinedServices, default_behavior) {\n+  auto node_handle = rclcpp::node::Node::make_shared(\"base_node\");\n+\n+  try {\n+    auto srv = node_handle->create_service<rclcpp::srv::Mock>(\"test\",\n+        callback);\n+  } catch (const std::exception & e) {\n+    FAIL();\n+    return;\n+  }\n+  SUCCEED();\n+}\n+\n+\n+TEST_F(TestExternallyDefinedServices, extern_defined_uninitialized) {\n+  auto node_handle = rclcpp::node::Node::make_shared(\"base_node\");\n+\n+  // mock for externally defined service\n+  rcl_service_t service_handle = rcl_get_zero_initialized_service();\n+\n+  rclcpp::any_service_callback::AnyServiceCallback<rclcpp::srv::Mock> cb;\n+\n+  // don't initialize the service\n+  // expect fail\n+  try {\n+    rclcpp::service::Service<rclcpp::srv::Mock>(node_handle->get_rcl_node_handle(),\n+      &service_handle, cb);\n+  } catch (const std::runtime_error & e) {\n+    SUCCEED();\n+    return;\n+  }\n+\n+  FAIL();\n+}\n+\n+TEST_F(TestExternallyDefinedServices, extern_defined_initialized) {\n+  auto node_handle = rclcpp::node::Node::make_shared(\"base_node\");\n+\n+  // mock for externally defined service\n+  rcl_service_t service_handle = rcl_get_zero_initialized_service();\n+  rcl_service_options_t service_options = rcl_service_get_default_options();\n+  const rosidl_service_type_support_t * ts = ROSIDL_GET_TYPE_SUPPORT(\n+    rclcpp, srv, Mock);\n+  if (rcl_service_init(&service_handle, node_handle->get_rcl_node_handle(),\n+    ts, \"base_node_service\", &service_options) != RCL_RET_OK)\n+  {\n+    FAIL();\n+    return;\n+  }\n+  rclcpp::any_service_callback::AnyServiceCallback<rclcpp::srv::Mock> cb;\n+  // don't initialize the service\n+  // expect fail","path":"rclcpp/test/test_externally_defined_services.cpp","position":95,"original_position":95,"commit_id":"81a07847461ec4f9e1a4f4b54d3b8e1df40f83c3","original_commit_id":"81a07847461ec4f9e1a4f4b54d3b8e1df40f83c3","user":{"login":"Karsten1987","id":5419873,"avatar_url":"https://avatars.githubusercontent.com/u/5419873?v=3","gravatar_id":"","url":"https://api.github.com/users/Karsten1987","html_url":"https://github.com/Karsten1987","followers_url":"https://api.github.com/users/Karsten1987/followers","following_url":"https://api.github.com/users/Karsten1987/following{/other_user}","gists_url":"https://api.github.com/users/Karsten1987/gists{/gist_id}","starred_url":"https://api.github.com/users/Karsten1987/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Karsten1987/subscriptions","organizations_url":"https://api.github.com/users/Karsten1987/orgs","repos_url":"https://api.github.com/users/Karsten1987/repos","events_url":"https://api.github.com/users/Karsten1987/events{/privacy}","received_events_url":"https://api.github.com/users/Karsten1987/received_events","type":"User","site_admin":false},"body":"that must be an erroneous copy-paste","created_at":"2016-11-29T05:07:37Z","updated_at":"2016-11-29T05:07:37Z","html_url":"https://github.com/ros2/rclcpp/pull/279#discussion_r89942011","pull_request_url":"https://api.github.com/repos/ros2/rclcpp/pulls/279","_links":{"self":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/comments/89942011"},"html":{"href":"https://github.com/ros2/rclcpp/pull/279#discussion_r89942011"},"pull_request":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/279"}}},"pull_request":{"url":"https://api.github.com/repos/ros2/rclcpp/pulls/279","id":94457625,"html_url":"https://github.com/ros2/rclcpp/pull/279","diff_url":"https://github.com/ros2/rclcpp/pull/279.diff","patch_url":"https://github.com/ros2/rclcpp/pull/279.patch","issue_url":"https://api.github.com/repos/ros2/rclcpp/issues/279","number":279,"state":"open","locked":false,"title":"(dev) construct service from existing rcl_service_t","user":{"login":"Karsten1987","id":5419873,"avatar_url":"https://avatars.githubusercontent.com/u/5419873?v=3","gravatar_id":"","url":"https://api.github.com/users/Karsten1987","html_url":"https://github.com/Karsten1987","followers_url":"https://api.github.com/users/Karsten1987/followers","following_url":"https://api.github.com/users/Karsten1987/following{/other_user}","gists_url":"https://api.github.com/users/Karsten1987/gists{/gist_id}","starred_url":"https://api.github.com/users/Karsten1987/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Karsten1987/subscriptions","organizations_url":"https://api.github.com/users/Karsten1987/orgs","repos_url":"https://api.github.com/users/Karsten1987/repos","events_url":"https://api.github.com/users/Karsten1987/events{/privacy}","received_events_url":"https://api.github.com/users/Karsten1987/received_events","type":"User","site_admin":false},"body":"this PR enables a wrapping around a rcl_service_t which is externally initialized. The goal here is to instantiate a service on the rcl level and still be able to add it into a rclcpp executor. \r\n\r\nOn the flipside, I have to have a boolean flag stating whether we own ownership over this service or not. This becomes important when trying to destroy the service. ","created_at":"2016-11-18T23:53:03Z","updated_at":"2016-11-29T05:07:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7f92925cff2bccdf4be5648c7aaab5cc29eebacd","assignee":{"login":"Karsten1987","id":5419873,"avatar_url":"https://avatars.githubusercontent.com/u/5419873?v=3","gravatar_id":"","url":"https://api.github.com/users/Karsten1987","html_url":"https://github.com/Karsten1987","followers_url":"https://api.github.com/users/Karsten1987/followers","following_url":"https://api.github.com/users/Karsten1987/following{/other_user}","gists_url":"https://api.github.com/users/Karsten1987/gists{/gist_id}","starred_url":"https://api.github.com/users/Karsten1987/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Karsten1987/subscriptions","organizations_url":"https://api.github.com/users/Karsten1987/orgs","repos_url":"https://api.github.com/users/Karsten1987/repos","events_url":"https://api.github.com/users/Karsten1987/events{/privacy}","received_events_url":"https://api.github.com/users/Karsten1987/received_events","type":"User","site_admin":false},"assignees":[{"login":"Karsten1987","id":5419873,"avatar_url":"https://avatars.githubusercontent.com/u/5419873?v=3","gravatar_id":"","url":"https://api.github.com/users/Karsten1987","html_url":"https://github.com/Karsten1987","followers_url":"https://api.github.com/users/Karsten1987/followers","following_url":"https://api.github.com/users/Karsten1987/following{/other_user}","gists_url":"https://api.github.com/users/Karsten1987/gists{/gist_id}","starred_url":"https://api.github.com/users/Karsten1987/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Karsten1987/subscriptions","organizations_url":"https://api.github.com/users/Karsten1987/orgs","repos_url":"https://api.github.com/users/Karsten1987/repos","events_url":"https://api.github.com/users/Karsten1987/events{/privacy}","received_events_url":"https://api.github.com/users/Karsten1987/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ros2/rclcpp/pulls/279/commits","review_comments_url":"https://api.github.com/repos/ros2/rclcpp/pulls/279/comments","review_comment_url":"https://api.github.com/repos/ros2/rclcpp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ros2/rclcpp/issues/279/comments","statuses_url":"https://api.github.com/repos/ros2/rclcpp/statuses/81a07847461ec4f9e1a4f4b54d3b8e1df40f83c3","head":{"label":"ros2:service_refactor","ref":"service_refactor","sha":"81a07847461ec4f9e1a4f4b54d3b8e1df40f83c3","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}","deployments_url":"https://api.github.com/repos/ros2/rclcpp/deployments","created_at":"2014-08-07T21:36:38Z","updated_at":"2016-11-28T21:08:13Z","pushed_at":"2016-11-29T04:20:06Z","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":1140,"stargazers_count":15,"watchers_count":15,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":43,"forks":14,"open_issues":43,"watchers":15,"default_branch":"master"}},"base":{"label":"ros2:master","ref":"master","sha":"aa2d0a395486d46cd80ec26518aa4fc63a9cd21e","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}","deployments_url":"https://api.github.com/repos/ros2/rclcpp/deployments","created_at":"2014-08-07T21:36:38Z","updated_at":"2016-11-28T21:08:13Z","pushed_at":"2016-11-29T04:20:06Z","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":1140,"stargazers_count":15,"watchers_count":15,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":43,"forks":14,"open_issues":43,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/279"},"html":{"href":"https://github.com/ros2/rclcpp/pull/279"},"issue":{"href":"https://api.github.com/repos/ros2/rclcpp/issues/279"},"comments":{"href":"https://api.github.com/repos/ros2/rclcpp/issues/279/comments"},"review_comments":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/279/comments"},"review_comment":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/279/commits"},"statuses":{"href":"https://api.github.com/repos/ros2/rclcpp/statuses/81a07847461ec4f9e1a4f4b54d3b8e1df40f83c3"}}}}
{"actor":{"display_login":"Karsten1987"}}