{"action":"created","comment":{"url":"https://api.github.com/repos/ros2/rclcpp/pulls/comments/35362188","id":35362188,"diff_hunk":"@@ -0,0 +1,57 @@\n+// Copyright 2015 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_BOUNDED_MSG_MEMORY_STRATEGY_HPP_\n+#define RCLCPP_RCLCPP_BOUNDED_MSG_MEMORY_STRATEGY_HPP_\n+\n+#include <rclcpp/msg_memory_strategy.hpp>\n+#include <rclcpp/macros.hpp>\n+\n+namespace rclcpp\n+{\n+namespace single_msg_memory_strategy\n+{\n+\n+template<typename MessageT>\n+class SingleMessageMemoryStrategy :\n+  public msg_memory_strategy::MessageMemoryStrategy<MessageT>\n+{\n+public:\n+  RCLCPP_MAKE_SHARED_DEFINITIONS(SingleMessageMemoryStrategy);\n+  SingleMessageMemoryStrategy()\n+  {\n+    //typename std::enable_if<has_bounded_size<MessageT>::value, MessageT>::type message;\n+    MessageT message;\n+    message_ = std::make_shared<MessageT>(message);\n+  }\n+\n+  std::shared_ptr<void> borrow_message()\n+  {\n+    return message_;\n+  }\n+\n+  virtual void return_message(std::shared_ptr<void> &/*msg*/)\n+  {\n+  }","path":"rclcpp/include/rclcpp/strategies/single_msg_memory_strategy.hpp","position":46,"original_position":46,"commit_id":"f3e1c7884d5c52dd684a8143ec650e8e14772c7e","original_commit_id":"f3e1c7884d5c52dd684a8143ec650e8e14772c7e","user":{"login":"dirk-thomas","id":1335366,"avatar_url":"https://avatars.githubusercontent.com/u/1335366?v=3","gravatar_id":"","url":"https://api.github.com/users/dirk-thomas","html_url":"https://github.com/dirk-thomas","followers_url":"https://api.github.com/users/dirk-thomas/followers","following_url":"https://api.github.com/users/dirk-thomas/following{/other_user}","gists_url":"https://api.github.com/users/dirk-thomas/gists{/gist_id}","starred_url":"https://api.github.com/users/dirk-thomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dirk-thomas/subscriptions","organizations_url":"https://api.github.com/users/dirk-thomas/orgs","repos_url":"https://api.github.com/users/dirk-thomas/repos","events_url":"https://api.github.com/users/dirk-thomas/events{/privacy}","received_events_url":"https://api.github.com/users/dirk-thomas/received_events","type":"User","site_admin":false},"body":"Do I understand it correctly that the idea is to implement a `reset()` method on each message struct?\r\n\r\nI would argue against that. If we can make it work without requiring such a method we should do that. Any functionality we require on a message will significantly increase the effort to later allow user provided data types.","created_at":"2015-07-23T19:37:22Z","updated_at":"2015-07-23T19:37:22Z","html_url":"https://github.com/ros2/rclcpp/pull/64#discussion_r35362188","pull_request_url":"https://api.github.com/repos/ros2/rclcpp/pulls/64","_links":{"self":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/comments/35362188"},"html":{"href":"https://github.com/ros2/rclcpp/pull/64#discussion_r35362188"},"pull_request":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/ros2/rclcpp/pulls/64","id":40612480,"html_url":"https://github.com/ros2/rclcpp/pull/64","diff_url":"https://github.com/ros2/rclcpp/pull/64.diff","patch_url":"https://github.com/ros2/rclcpp/pull/64.patch","issue_url":"https://api.github.com/repos/ros2/rclcpp/issues/64","number":64,"state":"open","locked":false,"title":"Create MessageMemoryStrategy for subscribers","user":{"login":"jacquelinekay","id":495933,"avatar_url":"https://avatars.githubusercontent.com/u/495933?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquelinekay","html_url":"https://github.com/jacquelinekay","followers_url":"https://api.github.com/users/jacquelinekay/followers","following_url":"https://api.github.com/users/jacquelinekay/following{/other_user}","gists_url":"https://api.github.com/users/jacquelinekay/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquelinekay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquelinekay/subscriptions","organizations_url":"https://api.github.com/users/jacquelinekay/orgs","repos_url":"https://api.github.com/users/jacquelinekay/repos","events_url":"https://api.github.com/users/jacquelinekay/events{/privacy}","received_events_url":"https://api.github.com/users/jacquelinekay/received_events","type":"User","site_admin":false},"body":"To avoid `new` whenever a message is received by the subscriber, abstract out the memory strategy for subscribers. `MessageMemoryStrategy` is templated on the message type and gets passed to the subscriber constructor.\r\n\r\nExample usage in https://github.com/ros2/examples/pull/39","created_at":"2015-07-22T21:14:14Z","updated_at":"2015-07-23T19:37:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8043c4cea6af4d1107b8190fe09bd63fd21a2cf7","assignee":{"login":"jacquelinekay","id":495933,"avatar_url":"https://avatars.githubusercontent.com/u/495933?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquelinekay","html_url":"https://github.com/jacquelinekay","followers_url":"https://api.github.com/users/jacquelinekay/followers","following_url":"https://api.github.com/users/jacquelinekay/following{/other_user}","gists_url":"https://api.github.com/users/jacquelinekay/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquelinekay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquelinekay/subscriptions","organizations_url":"https://api.github.com/users/jacquelinekay/orgs","repos_url":"https://api.github.com/users/jacquelinekay/repos","events_url":"https://api.github.com/users/jacquelinekay/events{/privacy}","received_events_url":"https://api.github.com/users/jacquelinekay/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ros2/rclcpp/pulls/64/commits","review_comments_url":"https://api.github.com/repos/ros2/rclcpp/pulls/64/comments","review_comment_url":"https://api.github.com/repos/ros2/rclcpp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ros2/rclcpp/issues/64/comments","statuses_url":"https://api.github.com/repos/ros2/rclcpp/statuses/f3e1c7884d5c52dd684a8143ec650e8e14772c7e","head":{"label":"ros2:msg_memory_strategy","ref":"msg_memory_strategy","sha":"f3e1c7884d5c52dd684a8143ec650e8e14772c7e","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-05-23T23:59:54Z","pushed_at":"2015-07-23T18:18:33Z","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":1440,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":6,"default_branch":"master"}},"base":{"label":"ros2:master","ref":"master","sha":"3902ba2ddbe83c99ac868c97aa3ea421e9238a73","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-05-23T23:59:54Z","pushed_at":"2015-07-23T18:18:33Z","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":1440,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/64"},"html":{"href":"https://github.com/ros2/rclcpp/pull/64"},"issue":{"href":"https://api.github.com/repos/ros2/rclcpp/issues/64"},"comments":{"href":"https://api.github.com/repos/ros2/rclcpp/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ros2/rclcpp/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/ros2/rclcpp/statuses/f3e1c7884d5c52dd684a8143ec650e8e14772c7e"}}}}