GitHub PullRequestReviewCommentEvent at 2014-11-06 18:09:54
Repository: opensim-core
Actor: aseth1
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments/19962332","id":19962332,"diff_hunk":"@@ -0,0 +1,145 @@\n+#ifndef OPENSIM_COMPONENT_LIST_H_\n+#define OPENSIM_COMPONENT_LIST_H_\n+/* -------------------------------------------------------------------------- *\n+ *                             OpenSim: ComponentList.h                           *\n+ * -------------------------------------------------------------------------- *\n+ * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *\n+ * See http://opensim.stanford.edu and the NOTICE file for more information.  *\n+ * OpenSim is developed at Stanford University and supported by the US        *\n+ * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *\n+ * through the Warrior Web program.                                           *\n+ *                                                                            *\n+ * Copyright (c) 2005-2014 Stanford University and the Authors                *\n+ * Author(s): Ayman Habib                                                     *\n+ *                                                                            *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may    *\n+ * not use this file except in compliance with the License. You may obtain a  *\n+ * copy of the License at 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+\n+// INCLUDES\n+#include <OpenSim/Common/osimCommonDLL.h>\n+#include \"OpenSim/Common/Object.h\"\n+#include \"Simbody.h\"\n+\n+namespace OpenSim {\n+\n+class Component;\n+\n+template <typename T> class ComponentListIterator;\n+//==============================================================================\n+//                            OPENSIM ComponentList\n+//==============================================================================\n+// Class used to help iterate over specific Components\n+//\n+/**\n+* A class to specifiy a filter to be used to iterate thru compoenents. More flexible than filtering\n+* based on Type only. To write your custom filter, extend this class and implement the choose method.\n+* This's more typical visitor design pattern\n+*/\n+class ComponentFilter {\n+public:\n+    ComponentFilter() {};\n+    virtual bool choose(const Component* comp) const = 0;\n+    virtual ~ComponentFilter() {}\n+};\n+/**\n+* A class to filter components based on Type, used as default filter for iterator\n+*/\n+template <typename T>\n+class ComponentFilterByType : public ComponentFilter {\n+public:\n+    ComponentFilterByType() {};\n+    bool choose(const Component* comp) const {\n+        return dynamic_cast<const T*>(comp) != nullptr;\n+    };\n+    virtual ~ComponentFilterByType() {}\n+\n+};\n+/**\n+* Collection of components to iterate through\n+*/\n+template <typename T>\n+class ComponentList {\n+public:\n+    typedef ComponentListIterator<T> iterator;\n+    typedef ComponentFilter filter;\n+#ifndef SWIG\n+    ComponentList(const Component* root, filter* f = new ComponentFilterByType<T>()) : m_root(root), m_filter(f){}\n+#else\n+    ComponentList(const Component* root) : m_root(root), m_filter(new ComponentFilterByType<T>()){}\n+#endif\n+    virtual ~ComponentList() { delete m_filter;  }\n+    ComponentListIterator<T> begin() {\n+        return ComponentListIterator<T>(m_root, m_filter);\n+    }\n+    void setFilter(filter* filter){\n+        m_filter = filter;\n+    }\n+    ComponentListIterator<T> end() {\n+        return nullptr;\n+    }\n+private:\n+    const Component* m_root;\n+    filter* m_filter;\n+    friend class ComponentListIterator<T>;\n+};\n+\n+//==============================================================================\n+//                            OPENSIM ComponentListIterator\n+//==============================================================================\n+// Class used to iterate over subcomponents of specific type, default to all Compoentns \n+//\n+/** Usa as:\n+@code\n+ComponentList<GeometryPath> geomPathList = model.getComponentList<GeometryPath>();\n+for (const GeometryPath& gpath : geomPathList) {\n+    // do something with gpath\n+}\n+@endcode","path":"OpenSim/Common/ComponentList.h","position":105,"original_position":105,"commit_id":"ccf2ee856a8e6f21ccd4b2f75c77bbba968b01b0","original_commit_id":"ccf2ee856a8e6f21ccd4b2f75c77bbba968b01b0","user":{"login":"aseth1","id":6494122,"avatar_url":"https://avatars.githubusercontent.com/u/6494122?v=2","gravatar_id":"","url":"https://api.github.com/users/aseth1","html_url":"https://github.com/aseth1","followers_url":"https://api.github.com/users/aseth1/followers","following_url":"https://api.github.com/users/aseth1/following{/other_user}","gists_url":"https://api.github.com/users/aseth1/gists{/gist_id}","starred_url":"https://api.github.com/users/aseth1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aseth1/subscriptions","organizations_url":"https://api.github.com/users/aseth1/orgs","repos_url":"https://api.github.com/users/aseth1/repos","events_url":"https://api.github.com/users/aseth1/events{/privacy}","received_events_url":"https://api.github.com/users/aseth1/received_events","type":"User","site_admin":false},"body":"This is awesome Ayman!","created_at":"2014-11-06T18:09:54Z","updated_at":"2014-11-06T18:09:54Z","html_url":"https://github.com/opensim-org/opensim-core/pull/235#discussion_r19962332","pull_request_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/235","_links":{"self":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments/19962332"},"html":{"href":"https://github.com/opensim-org/opensim-core/pull/235#discussion_r19962332"},"pull_request":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/235"}}},"pull_request":{"url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/235","id":23988220,"html_url":"https://github.com/opensim-org/opensim-core/pull/235","diff_url":"https://github.com/opensim-org/opensim-core/pull/235.diff","patch_url":"https://github.com/opensim-org/opensim-core/pull/235.patch","issue_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/235","number":235,"state":"open","locked":false,"title":"Iterator","user":{"login":"aymanhab","id":3972208,"avatar_url":"https://avatars.githubusercontent.com/u/3972208?v=2","gravatar_id":"","url":"https://api.github.com/users/aymanhab","html_url":"https://github.com/aymanhab","followers_url":"https://api.github.com/users/aymanhab/followers","following_url":"https://api.github.com/users/aymanhab/following{/other_user}","gists_url":"https://api.github.com/users/aymanhab/gists{/gist_id}","starred_url":"https://api.github.com/users/aymanhab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aymanhab/subscriptions","organizations_url":"https://api.github.com/users/aymanhab/orgs","repos_url":"https://api.github.com/users/aymanhab/repos","events_url":"https://api.github.com/users/aymanhab/events{/privacy}","received_events_url":"https://api.github.com/users/aymanhab/received_events","type":"User","site_admin":false},"body":"Implementation of an iterator that goes thru a Component and all its sub-components in a tree (pre-order) traversal. A test case that demonstrates the usage is also included, along with wrapping to make these iterators accessible from scripting..","created_at":"2014-11-06T15:30:32Z","updated_at":"2014-11-06T18:09:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"233bae36efcf21cea77109184c33f71d97b881eb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/235/commits","review_comments_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/235/comments","review_comment_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments/{number}","comments_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/235/comments","statuses_url":"https://api.github.com/repos/opensim-org/opensim-core/statuses/ccf2ee856a8e6f21ccd4b2f75c77bbba968b01b0","head":{"label":"opensim-org:iterator","ref":"iterator","sha":"ccf2ee856a8e6f21ccd4b2f75c77bbba968b01b0","user":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars.githubusercontent.com/u/4370782?v=2","gravatar_id":"","url":"https://api.github.com/users/opensim-org","html_url":"https://github.com/opensim-org","followers_url":"https://api.github.com/users/opensim-org/followers","following_url":"https://api.github.com/users/opensim-org/following{/other_user}","gists_url":"https://api.github.com/users/opensim-org/gists{/gist_id}","starred_url":"https://api.github.com/users/opensim-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensim-org/subscriptions","organizations_url":"https://api.github.com/users/opensim-org/orgs","repos_url":"https://api.github.com/users/opensim-org/repos","events_url":"https://api.github.com/users/opensim-org/events{/privacy}","received_events_url":"https://api.github.com/users/opensim-org/received_events","type":"Organization","site_admin":false},"repo":{"id":20775600,"name":"opensim-core","full_name":"opensim-org/opensim-core","owner":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars.githubusercontent.com/u/4370782?v=2","gravatar_id":"","url":"https://api.github.com/users/opensim-org","html_url":"https://github.com/opensim-org","followers_url":"https://api.github.com/users/opensim-org/followers","following_url":"https://api.github.com/users/opensim-org/following{/other_user}","gists_url":"https://api.github.com/users/opensim-org/gists{/gist_id}","starred_url":"https://api.github.com/users/opensim-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensim-org/subscriptions","organizations_url":"https://api.github.com/users/opensim-org/orgs","repos_url":"https://api.github.com/users/opensim-org/repos","events_url":"https://api.github.com/users/opensim-org/events{/privacy}","received_events_url":"https://api.github.com/users/opensim-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opensim-org/opensim-core","description":"SimTK OpenSim C++ libraries and comand-line applications and Java/Python wrapping.","fork":false,"url":"https://api.github.com/repos/opensim-org/opensim-core","forks_url":"https://api.github.com/repos/opensim-org/opensim-core/forks","keys_url":"https://api.github.com/repos/opensim-org/opensim-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opensim-org/opensim-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opensim-org/opensim-core/teams","hooks_url":"https://api.github.com/repos/opensim-org/opensim-core/hooks","issue_events_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/events{/number}","events_url":"https://api.github.com/repos/opensim-org/opensim-core/events","assignees_url":"https://api.github.com/repos/opensim-org/opensim-core/assignees{/user}","branches_url":"https://api.github.com/repos/opensim-org/opensim-core/branches{/branch}","tags_url":"https://api.github.com/repos/opensim-org/opensim-core/tags","blobs_url":"https://api.github.com/repos/opensim-org/opensim-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opensim-org/opensim-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opensim-org/opensim-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/opensim-org/opensim-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opensim-org/opensim-core/statuses/{sha}","languages_url":"https://api.github.com/repos/opensim-org/opensim-core/languages","stargazers_url":"https://api.github.com/repos/opensim-org/opensim-core/stargazers","contributors_url":"https://api.github.com/repos/opensim-org/opensim-core/contributors","subscribers_url":"https://api.github.com/repos/opensim-org/opensim-core/subscribers","subscription_url":"https://api.github.com/repos/opensim-org/opensim-core/subscription","commits_url":"https://api.github.com/repos/opensim-org/opensim-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/opensim-org/opensim-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/opensim-org/opensim-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/comments/{number}","contents_url":"https://api.github.com/repos/opensim-org/opensim-core/contents/{+path}","compare_url":"https://api.github.com/repos/opensim-org/opensim-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opensim-org/opensim-core/merges","archive_url":"https://api.github.com/repos/opensim-org/opensim-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opensim-org/opensim-core/downloads","issues_url":"https://api.github.com/repos/opensim-org/opensim-core/issues{/number}","pulls_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls{/number}","milestones_url":"https://api.github.com/repos/opensim-org/opensim-core/milestones{/number}","notifications_url":"https://api.github.com/repos/opensim-org/opensim-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opensim-org/opensim-core/labels{/name}","releases_url":"https://api.github.com/repos/opensim-org/opensim-core/releases{/id}","created_at":"2014-06-12T16:57:56Z","updated_at":"2014-10-20T01:00:48Z","pushed_at":"2014-11-06T15:26:25Z","git_url":"git://github.com/opensim-org/opensim-core.git","ssh_url":"git@github.com:opensim-org/opensim-core.git","clone_url":"https://github.com/opensim-org/opensim-core.git","svn_url":"https://github.com/opensim-org/opensim-core","homepage":"opensim.stanford.edu","size":114005,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":91,"forks":4,"open_issues":91,"watchers":6,"default_branch":"master"}},"base":{"label":"opensim-org:master","ref":"master","sha":"af948815c2cc1a052d167694cb7dba0e1d562eb5","user":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars.githubusercontent.com/u/4370782?v=2","gravatar_id":"","url":"https://api.github.com/users/opensim-org","html_url":"https://github.com/opensim-org","followers_url":"https://api.github.com/users/opensim-org/followers","following_url":"https://api.github.com/users/opensim-org/following{/other_user}","gists_url":"https://api.github.com/users/opensim-org/gists{/gist_id}","starred_url":"https://api.github.com/users/opensim-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensim-org/subscriptions","organizations_url":"https://api.github.com/users/opensim-org/orgs","repos_url":"https://api.github.com/users/opensim-org/repos","events_url":"https://api.github.com/users/opensim-org/events{/privacy}","received_events_url":"https://api.github.com/users/opensim-org/received_events","type":"Organization","site_admin":false},"repo":{"id":20775600,"name":"opensim-core","full_name":"opensim-org/opensim-core","owner":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars.githubusercontent.com/u/4370782?v=2","gravatar_id":"","url":"https://api.github.com/users/opensim-org","html_url":"https://github.com/opensim-org","followers_url":"https://api.github.com/users/opensim-org/followers","following_url":"https://api.github.com/users/opensim-org/following{/other_user}","gists_url":"https://api.github.com/users/opensim-org/gists{/gist_id}","starred_url":"https://api.github.com/users/opensim-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensim-org/subscriptions","organizations_url":"https://api.github.com/users/opensim-org/orgs","repos_url":"https://api.github.com/users/opensim-org/repos","events_url":"https://api.github.com/users/opensim-org/events{/privacy}","received_events_url":"https://api.github.com/users/opensim-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opensim-org/opensim-core","description":"SimTK OpenSim C++ libraries and comand-line applications and Java/Python wrapping.","fork":false,"url":"https://api.github.com/repos/opensim-org/opensim-core","forks_url":"https://api.github.com/repos/opensim-org/opensim-core/forks","keys_url":"https://api.github.com/repos/opensim-org/opensim-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opensim-org/opensim-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opensim-org/opensim-core/teams","hooks_url":"https://api.github.com/repos/opensim-org/opensim-core/hooks","issue_events_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/events{/number}","events_url":"https://api.github.com/repos/opensim-org/opensim-core/events","assignees_url":"https://api.github.com/repos/opensim-org/opensim-core/assignees{/user}","branches_url":"https://api.github.com/repos/opensim-org/opensim-core/branches{/branch}","tags_url":"https://api.github.com/repos/opensim-org/opensim-core/tags","blobs_url":"https://api.github.com/repos/opensim-org/opensim-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opensim-org/opensim-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opensim-org/opensim-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/opensim-org/opensim-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opensim-org/opensim-core/statuses/{sha}","languages_url":"https://api.github.com/repos/opensim-org/opensim-core/languages","stargazers_url":"https://api.github.com/repos/opensim-org/opensim-core/stargazers","contributors_url":"https://api.github.com/repos/opensim-org/opensim-core/contributors","subscribers_url":"https://api.github.com/repos/opensim-org/opensim-core/subscribers","subscription_url":"https://api.github.com/repos/opensim-org/opensim-core/subscription","commits_url":"https://api.github.com/repos/opensim-org/opensim-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/opensim-org/opensim-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/opensim-org/opensim-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/comments/{number}","contents_url":"https://api.github.com/repos/opensim-org/opensim-core/contents/{+path}","compare_url":"https://api.github.com/repos/opensim-org/opensim-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opensim-org/opensim-core/merges","archive_url":"https://api.github.com/repos/opensim-org/opensim-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opensim-org/opensim-core/downloads","issues_url":"https://api.github.com/repos/opensim-org/opensim-core/issues{/number}","pulls_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls{/number}","milestones_url":"https://api.github.com/repos/opensim-org/opensim-core/milestones{/number}","notifications_url":"https://api.github.com/repos/opensim-org/opensim-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opensim-org/opensim-core/labels{/name}","releases_url":"https://api.github.com/repos/opensim-org/opensim-core/releases{/id}","created_at":"2014-06-12T16:57:56Z","updated_at":"2014-10-20T01:00:48Z","pushed_at":"2014-11-06T15:26:25Z","git_url":"git://github.com/opensim-org/opensim-core.git","ssh_url":"git@github.com:opensim-org/opensim-core.git","clone_url":"https://github.com/opensim-org/opensim-core.git","svn_url":"https://github.com/opensim-org/opensim-core","homepage":"opensim.stanford.edu","size":114005,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":91,"forks":4,"open_issues":91,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/235"},"html":{"href":"https://github.com/opensim-org/opensim-core/pull/235"},"issue":{"href":"https://api.github.com/repos/opensim-org/opensim-core/issues/235"},"comments":{"href":"https://api.github.com/repos/opensim-org/opensim-core/issues/235/comments"},"review_comments":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/235/comments"},"review_comment":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/235/commits"},"statuses":{"href":"https://api.github.com/repos/opensim-org/opensim-core/statuses/ccf2ee856a8e6f21ccd4b2f75c77bbba968b01b0"}}}}