{"action":"created","comment":{"url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments/32601673","id":32601673,"diff_hunk":"@@ -0,0 +1,1142 @@\n+/* -------------------------------------------------------------------------- *\n+ *                            OpenSim:  DataTable.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-2015 Stanford University and the Authors                *\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+/** \\file\n+* This file defines the  DataTable class, which is used by OpenSim to provide  *\n+* an in-memory container for data access and manipulation.                     *\n+*/\n+\n+#ifndef OPENSIM_DATA_TABLE_H_\n+#define OPENSIM_DATA_TABLE_H_\n+\n+// Standard headers.\n+#include <memory>\n+#include <unordered_map>\n+#include <utility>\n+#include <vector>\n+#include <string>\n+#include <type_traits>\n+#include <limits>\n+// Non-standard headers.\n+#include <SimTKcommon.h>\n+\n+\n+namespace OpenSim {\n+  class AbstractDataTable;\n+  template<typename ET> class DataTable_;\n+\n+  using DataTable = DataTable_<SimTK::Real>;\n+\n+  /// Enum to specify if the the input iterator is traversing data row-wise or\n+  /// col-wise.\n+  /// clang3.6 crashes if this is turned to a \"enum class\". Until it is fixed,\n+  /// use a pre c++11 enum.\n+  enum InputItDir{\n+    ROWWISE, \n+    COLWISE\n+  };\n+\n+  /// Bind two DataTables by row.\n+  template<typename ET>\n+  DataTable_<ET> rbindDataTables(const DataTable_<ET>& dt1, \n+                                 const DataTable_<ET>& dt2);\n+\n+  /// Bind two DataTables by col.\n+  template<typename ET>\n+  DataTable_<ET> cbindDataTables(const DataTable_<ET>& dt1, \n+                                 const DataTable_<ET>& dt2);\n+\n+  // Exceptions.\n+  class ColumnDoesNotExist;\n+  class ColumnHasLabel;\n+  class ColumnHasNoLabel;\n+  class ZeroElements;\n+  class InvalidEntry;\n+  class MetaDataKeyExists;\n+  class MetaDataKeyDoesNotExist;\n+  class MetaDataTypeMismatch;\n+} // namespace OpenSim\n+\n+\n+/**----------------------------------------------------------------------------*\n+* AbstractDataTable is the base-class of all DataTable_ allowing storage of    *\n+* DataTable_ of different types to be stored in containers. See Datatable_ for *\n+* details on the interface.                                                    *\n+*-----------------------------------------------------------------------------*/\n+class OpenSim::AbstractDataTable {\n+public:\n+  AbstractDataTable() = default;\n+  AbstractDataTable(const AbstractDataTable&) = delete;\n+  AbstractDataTable(AbstractDataTable&&) = delete;\n+  virtual std::unique_ptr<AbstractDataTable> clone() const = 0;\n+  virtual ~AbstractDataTable() {}\n+}; // AbstractDataTable\n+\n+class OpenSim::ColumnDoesNotExist : public std::runtime_error {\n+public:\n+  ColumnDoesNotExist(const std::string& expl) : runtime_error(expl) {}\n+};\n+\n+class OpenSim::ColumnHasLabel : public std::runtime_error {\n+public:\n+  ColumnHasLabel(const std::string& expl) : runtime_error(expl) {}\n+};\n+\n+class OpenSim::ColumnHasNoLabel : public std::runtime_error {\n+public:\n+  ColumnHasNoLabel(const std::string& expl) : runtime_error(expl) {}\n+};\n+\n+class OpenSim::ZeroElements : public std::runtime_error {\n+public:\n+  ZeroElements(const std::string& expl) : runtime_error(expl) {}\n+};\n+\n+class OpenSim::InvalidEntry : public std::runtime_error {\n+public:\n+  InvalidEntry(const std::string& expl) : runtime_error(expl) {}\n+};\n+\n+class OpenSim::MetaDataKeyExists : public std::runtime_error {\n+public:\n+  MetaDataKeyExists(const std::string& expl) : runtime_error(expl) {}\n+};\n+\n+class OpenSim::MetaDataKeyDoesNotExist : public std::runtime_error {\n+public:\n+  MetaDataKeyDoesNotExist(const std::string& expl) : runtime_error(expl) {}\n+};\n+\n+class OpenSim::MetaDataTypeMismatch : public std::runtime_error {\n+public:\n+  MetaDataTypeMismatch(const std::string& expl) : runtime_error(expl) {}\n+};","path":"OpenSim/Common/DataTable.h","position":132,"original_position":132,"commit_id":"08f427194f7452193805e8c31e24f26616586fb8","original_commit_id":"08f427194f7452193805e8c31e24f26616586fb8","user":{"login":"aseth1","id":6494122,"avatar_url":"https://avatars.githubusercontent.com/u/6494122?v=3","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":"Good point. We could have OpenSim::Exception derive from `std::runtime_error` too.\r\nIt is great to see the error conditions thought out upfront! ","created_at":"2015-06-17T07:39:33Z","updated_at":"2015-06-17T07:39:33Z","html_url":"https://github.com/opensim-org/opensim-core/pull/499#discussion_r32601673","pull_request_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/499","_links":{"self":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments/32601673"},"html":{"href":"https://github.com/opensim-org/opensim-core/pull/499#discussion_r32601673"},"pull_request":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/499"}}},"pull_request":{"url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/499","id":37831134,"html_url":"https://github.com/opensim-org/opensim-core/pull/499","diff_url":"https://github.com/opensim-org/opensim-core/pull/499.diff","patch_url":"https://github.com/opensim-org/opensim-core/pull/499.patch","issue_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/499","number":499,"state":"open","locked":false,"title":"[WIP] DataTable Class","user":{"login":"klshrinidhi","id":1181669,"avatar_url":"https://avatars.githubusercontent.com/u/1181669?v=3","gravatar_id":"","url":"https://api.github.com/users/klshrinidhi","html_url":"https://github.com/klshrinidhi","followers_url":"https://api.github.com/users/klshrinidhi/followers","following_url":"https://api.github.com/users/klshrinidhi/following{/other_user}","gists_url":"https://api.github.com/users/klshrinidhi/gists{/gist_id}","starred_url":"https://api.github.com/users/klshrinidhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klshrinidhi/subscriptions","organizations_url":"https://api.github.com/users/klshrinidhi/orgs","repos_url":"https://api.github.com/users/klshrinidhi/repos","events_url":"https://api.github.com/users/klshrinidhi/events{/privacy}","received_events_url":"https://api.github.com/users/klshrinidhi/received_events","type":"User","site_admin":false},"body":"##### READY FOR REVIEW.\r\n\r\nRequesting review for following:\r\n* OpenSim/Common/DataTable.h -- This file contains the DataTable class. Conceptually, there are three parts to the DataTable -- the matrix, the column labels and the metadata. The construction and populating of DataTable can be done using an iterator(satisfying input-iterator requirements). Any object that behaves as an input iterator is acceptable. This means that DataTable need not know anything about the source of the data. I am happy to talk about the interface in a meeting if you like.\r\n* OpenSim/Examples/DataTable/example.cpp -- This file contains example usage of the DataTable interface. I am just demonstrating the usage of DataTable members. I am testing/checking the output of functions only certain points in the code. I have left the actual testing to the testing code. After the DataAdapter/DataReader classes are ready, I will add examples to create a DataTable by reading a file and creating an iterator that DataTable will accept.\r\n* OpenSim/Common/Test/DataTable.cpp -- This file contains all the testing code. I think I have covered all the decision routes in the code. It would be good if you can play with the class and try to break it.\r\n\r\nNotes:\r\n* OpenSim compiles and the above files execute successfully on Ubuntu 14.04 with clang-3.6. I will work on fixing any issues with Travis(which uses older compiler with older Ubuntu) builds but they should only be minor so review can happen simultaneously.\r\n* Currently time-series is not yet supported. I will be deriving the DataTable class to support time-series. Getting DataTable class reviewed will be good while I do that.\r\n* I will be working the DataAdapter/DataReader classes once the interface for DataTable is acceptable for everyone.","created_at":"2015-06-16T19:20:01Z","updated_at":"2015-06-17T07:39:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"33f7b36dcb4bb53952a4482f51449b5e2baac9ee","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/499/commits","review_comments_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/499/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/499/comments","statuses_url":"https://api.github.com/repos/opensim-org/opensim-core/statuses/08f427194f7452193805e8c31e24f26616586fb8","head":{"label":"opensim-org:DataHandlingInterfacePrototype","ref":"DataHandlingInterfacePrototype","sha":"08f427194f7452193805e8c31e24f26616586fb8","user":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars.githubusercontent.com/u/4370782?v=3","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=3","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 4.0 C++ libraries and command-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":"2015-06-14T11:28:58Z","pushed_at":"2015-06-17T03:25:49Z","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":"https://opensim.stanford.edu","size":112330,"stargazers_count":13,"watchers_count":13,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":206,"forks":9,"open_issues":206,"watchers":13,"default_branch":"master"}},"base":{"label":"opensim-org:master","ref":"master","sha":"562cee09404b5fe7337523c8b5c3a86238469ce8","user":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars.githubusercontent.com/u/4370782?v=3","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=3","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 4.0 C++ libraries and command-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":"2015-06-14T11:28:58Z","pushed_at":"2015-06-17T03:25:49Z","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":"https://opensim.stanford.edu","size":112330,"stargazers_count":13,"watchers_count":13,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":206,"forks":9,"open_issues":206,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/499"},"html":{"href":"https://github.com/opensim-org/opensim-core/pull/499"},"issue":{"href":"https://api.github.com/repos/opensim-org/opensim-core/issues/499"},"comments":{"href":"https://api.github.com/repos/opensim-org/opensim-core/issues/499/comments"},"review_comments":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/499/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/499/commits"},"statuses":{"href":"https://api.github.com/repos/opensim-org/opensim-core/statuses/08f427194f7452193805e8c31e24f26616586fb8"}}}}