{"action":"created","comment":{"url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/comments/90550276","pull_request_review_id":11066317,"id":90550276,"diff_hunk":"@@ -0,0 +1,121 @@\n+/*\n+* C++ Assembler Interpreter\n+* Copyright (C) 2016 Chair of Computer Architecture\n+* at Technical University of Munich\n+*\n+* This program is free software: you can redistribute it and/or modify\n+* it under the terms of the GNU General Public License as published by\n+* the Free Software Foundation, either version 3 of the License, or\n+* (at your option) any later version.\n+*\n+* This program is distributed in the hope that it will be useful,\n+* but WITHOUT ANY WARRANTY; without even the implied warranty of\n+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+* GNU General Public License for more details.\n+*\n+* You should have received a copy of the GNU General Public License\n+* along with this program. If not, see <http://www.gnu.org/licenses/>.\n+*/\n+\n+#include \"ui/snapshot-component.hpp\"\n+\n+#include <QFileInfo>\n+#include <QUrl>\n+#include <algorithm>\n+\n+#include \"arch/common/architecture-formula.hpp\"\n+#include \"common/utility.hpp\"\n+#include \"core/snapshot.hpp\"\n+\n+SnapshotComponent::SnapshotComponent(const std::string& path, QObject* parent)\n+: QObject(parent), _baseDirectory(QString::fromStdString(path)) {\n+  // check if snapshot directory exists, if not, create it.\n+  if (!_baseDirectory.exists()) {\n+    QString baseDirName = _baseDirectory.dirName();\n+    _baseDirectory.cdUp();\n+    _baseDirectory.mkpath(QString::fromStdString(path));\n+    _baseDirectory.cd(baseDirName);\n+  }\n+  QString fileExtensionFilter(_fileExtension);\n+  fileExtensionFilter.prepend(\"*\");\n+  QStringList filterList = {fileExtensionFilter};\n+  // Find all subdirectories and their snapshots\n+  auto subDirectories =\n+      _baseDirectory.entryList(QDir::AllDirs | QDir::NoDot | QDir::NoDotDot);\n+  for (const auto& subDirectoryName : subDirectories) {\n+    // There is a subdirectory for every combination of architecutre and\n+    // extensions.\n+    QDir subDirectory = _baseDirectory;\n+    if (subDirectory.cd(subDirectoryName)) {\n+      // Get all snapshots names in the directory.\n+      auto files = subDirectory.entryInfoList(\n+          filterList, QDir::Files | QDir::NoDot | QDir::NoDotDot);\n+      QSet<QString> snapshots;\n+      for (const auto& file : files) {\n+        snapshots.insert(file.completeBaseName());\n+      }\n+      _snapshotMap.insert(subDirectory.dirName(), snapshots);\n+    }\n+  }\n+}\n+\n+QStringList SnapshotComponent::getSnapshotList(const QString& architecture) {\n+  return _snapshotMap.value(architecture).toList();\n+}\n+\n+void SnapshotComponent::addSnapshot(const QString& architecture,\n+                                    const QString& snapshot,\n+                                    const std::string& data) {\n+  if (!_baseDirectory.exists(architecture)) {\n+    _baseDirectory.mkpath(architecture);\n+  }\n+  std::string path = snapshotPath(architecture, snapshot);\n+  Utility::storeToFile(path, data);\n+  _snapshotMap[architecture].insert(snapshot);\n+  emit snapshotsChanged();\n+}\n+\n+void SnapshotComponent::removeSnapshot(const QString& architecture,\n+                                       const QString& snapshot) {\n+  _snapshotMap[architecture].remove(snapshot);\n+  std::string path = snapshotPath(architecture, snapshot);\n+  std::remove(path.c_str());\n+  emit snapshotsChanged();\n+}\n+\n+std::string SnapshotComponent::snapshotPath(const QString& architecture,\n+                                            const QString& snapshot) {\n+  return Utility::joinPaths(_baseDirectory.absolutePath().toStdString(),\n+                            architecture.toStdString(),\n+                            snapshot.toStdString() + _fileExtension);\n+}\n+\n+void SnapshotComponent::importSnapshot(QUrl qPath) {\n+  std::string path = qPath.path().toStdString();\n+  try {\n+    Json json = Json::parse(Utility::loadFromFile(path));","path":"source/ui/snapshot-component.cpp","position":96,"original_position":96,"commit_id":"76e744ddc808df29303dcc27a30cb90e1d9292e9","original_commit_id":"76e744ddc808df29303dcc27a30cb90e1d9292e9","user":{"login":"goldsborough","id":6429851,"avatar_url":"https://avatars.githubusercontent.com/u/6429851?v=3","gravatar_id":"","url":"https://api.github.com/users/goldsborough","html_url":"https://github.com/goldsborough","followers_url":"https://api.github.com/users/goldsborough/followers","following_url":"https://api.github.com/users/goldsborough/following{/other_user}","gists_url":"https://api.github.com/users/goldsborough/gists{/gist_id}","starred_url":"https://api.github.com/users/goldsborough/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldsborough/subscriptions","organizations_url":"https://api.github.com/users/goldsborough/orgs","repos_url":"https://api.github.com/users/goldsborough/repos","events_url":"https://api.github.com/users/goldsborough/events{/privacy}","received_events_url":"https://api.github.com/users/goldsborough/received_events","type":"User","site_admin":false},"body":"`auto`","created_at":"2016-12-01T22:20:47Z","updated_at":"2016-12-01T22:28:37Z","html_url":"https://github.com/TUM-LRR/era-gp-sim/pull/164#discussion_r90550276","pull_request_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/164","_links":{"self":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/comments/90550276"},"html":{"href":"https://github.com/TUM-LRR/era-gp-sim/pull/164#discussion_r90550276"},"pull_request":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/164"}}},"pull_request":{"url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/164","id":95792934,"html_url":"https://github.com/TUM-LRR/era-gp-sim/pull/164","diff_url":"https://github.com/TUM-LRR/era-gp-sim/pull/164.diff","patch_url":"https://github.com/TUM-LRR/era-gp-sim/pull/164.patch","issue_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues/164","number":164,"state":"open","locked":false,"title":"Feature/snapshots","user":{"login":"janschopohl","id":18463279,"avatar_url":"https://avatars.githubusercontent.com/u/18463279?v=3","gravatar_id":"","url":"https://api.github.com/users/janschopohl","html_url":"https://github.com/janschopohl","followers_url":"https://api.github.com/users/janschopohl/followers","following_url":"https://api.github.com/users/janschopohl/following{/other_user}","gists_url":"https://api.github.com/users/janschopohl/gists{/gist_id}","starred_url":"https://api.github.com/users/janschopohl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janschopohl/subscriptions","organizations_url":"https://api.github.com/users/janschopohl/orgs","repos_url":"https://api.github.com/users/janschopohl/repos","events_url":"https://api.github.com/users/janschopohl/events{/privacy}","received_events_url":"https://api.github.com/users/janschopohl/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-29T22:52:26Z","updated_at":"2016-12-01T22:28:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"608ec90430e0d31d9d7d4ac1822c248139bde804","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/164/commits","review_comments_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/164/comments","review_comment_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues/164/comments","statuses_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/statuses/76e744ddc808df29303dcc27a30cb90e1d9292e9","head":{"label":"TUM-LRR:feature/snapshots","ref":"feature/snapshots","sha":"76e744ddc808df29303dcc27a30cb90e1d9292e9","user":{"login":"TUM-LRR","id":12150645,"avatar_url":"https://avatars.githubusercontent.com/u/12150645?v=3","gravatar_id":"","url":"https://api.github.com/users/TUM-LRR","html_url":"https://github.com/TUM-LRR","followers_url":"https://api.github.com/users/TUM-LRR/followers","following_url":"https://api.github.com/users/TUM-LRR/following{/other_user}","gists_url":"https://api.github.com/users/TUM-LRR/gists{/gist_id}","starred_url":"https://api.github.com/users/TUM-LRR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TUM-LRR/subscriptions","organizations_url":"https://api.github.com/users/TUM-LRR/orgs","repos_url":"https://api.github.com/users/TUM-LRR/repos","events_url":"https://api.github.com/users/TUM-LRR/events{/privacy}","received_events_url":"https://api.github.com/users/TUM-LRR/received_events","type":"Organization","site_admin":false},"repo":{"id":56257257,"name":"era-gp-sim","full_name":"TUM-LRR/era-gp-sim","owner":{"login":"TUM-LRR","id":12150645,"avatar_url":"https://avatars.githubusercontent.com/u/12150645?v=3","gravatar_id":"","url":"https://api.github.com/users/TUM-LRR","html_url":"https://github.com/TUM-LRR","followers_url":"https://api.github.com/users/TUM-LRR/followers","following_url":"https://api.github.com/users/TUM-LRR/following{/other_user}","gists_url":"https://api.github.com/users/TUM-LRR/gists{/gist_id}","starred_url":"https://api.github.com/users/TUM-LRR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TUM-LRR/subscriptions","organizations_url":"https://api.github.com/users/TUM-LRR/orgs","repos_url":"https://api.github.com/users/TUM-LRR/repos","events_url":"https://api.github.com/users/TUM-LRR/events{/privacy}","received_events_url":"https://api.github.com/users/TUM-LRR/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TUM-LRR/era-gp-sim","description":"ERA-Großpraktikum Simulatorentwicklung","fork":false,"url":"https://api.github.com/repos/TUM-LRR/era-gp-sim","forks_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/forks","keys_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/teams","hooks_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/hooks","issue_events_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues/events{/number}","events_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/events","assignees_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/assignees{/user}","branches_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/branches{/branch}","tags_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/tags","blobs_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/refs{/sha}","trees_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/statuses/{sha}","languages_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/languages","stargazers_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/stargazers","contributors_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/contributors","subscribers_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/subscribers","subscription_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/subscription","commits_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/commits{/sha}","git_commits_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/commits{/sha}","comments_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/comments{/number}","issue_comment_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues/comments{/number}","contents_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/contents/{+path}","compare_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/merges","archive_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/downloads","issues_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues{/number}","pulls_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls{/number}","milestones_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/milestones{/number}","notifications_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/labels{/name}","releases_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/releases{/id}","deployments_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/deployments","created_at":"2016-04-14T17:32:54Z","updated_at":"2016-10-23T22:36:58Z","pushed_at":"2016-12-01T18:04:45Z","git_url":"git://github.com/TUM-LRR/era-gp-sim.git","ssh_url":"git@github.com:TUM-LRR/era-gp-sim.git","clone_url":"https://github.com/TUM-LRR/era-gp-sim.git","svn_url":"https://github.com/TUM-LRR/era-gp-sim","homepage":null,"size":4737,"stargazers_count":11,"watchers_count":11,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":52,"forks":2,"open_issues":52,"watchers":11,"default_branch":"master"}},"base":{"label":"TUM-LRR:master","ref":"master","sha":"861a0df672bed5f74b44d6954193ba9387c7c68c","user":{"login":"TUM-LRR","id":12150645,"avatar_url":"https://avatars.githubusercontent.com/u/12150645?v=3","gravatar_id":"","url":"https://api.github.com/users/TUM-LRR","html_url":"https://github.com/TUM-LRR","followers_url":"https://api.github.com/users/TUM-LRR/followers","following_url":"https://api.github.com/users/TUM-LRR/following{/other_user}","gists_url":"https://api.github.com/users/TUM-LRR/gists{/gist_id}","starred_url":"https://api.github.com/users/TUM-LRR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TUM-LRR/subscriptions","organizations_url":"https://api.github.com/users/TUM-LRR/orgs","repos_url":"https://api.github.com/users/TUM-LRR/repos","events_url":"https://api.github.com/users/TUM-LRR/events{/privacy}","received_events_url":"https://api.github.com/users/TUM-LRR/received_events","type":"Organization","site_admin":false},"repo":{"id":56257257,"name":"era-gp-sim","full_name":"TUM-LRR/era-gp-sim","owner":{"login":"TUM-LRR","id":12150645,"avatar_url":"https://avatars.githubusercontent.com/u/12150645?v=3","gravatar_id":"","url":"https://api.github.com/users/TUM-LRR","html_url":"https://github.com/TUM-LRR","followers_url":"https://api.github.com/users/TUM-LRR/followers","following_url":"https://api.github.com/users/TUM-LRR/following{/other_user}","gists_url":"https://api.github.com/users/TUM-LRR/gists{/gist_id}","starred_url":"https://api.github.com/users/TUM-LRR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TUM-LRR/subscriptions","organizations_url":"https://api.github.com/users/TUM-LRR/orgs","repos_url":"https://api.github.com/users/TUM-LRR/repos","events_url":"https://api.github.com/users/TUM-LRR/events{/privacy}","received_events_url":"https://api.github.com/users/TUM-LRR/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TUM-LRR/era-gp-sim","description":"ERA-Großpraktikum Simulatorentwicklung","fork":false,"url":"https://api.github.com/repos/TUM-LRR/era-gp-sim","forks_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/forks","keys_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/teams","hooks_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/hooks","issue_events_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues/events{/number}","events_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/events","assignees_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/assignees{/user}","branches_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/branches{/branch}","tags_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/tags","blobs_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/refs{/sha}","trees_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/statuses/{sha}","languages_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/languages","stargazers_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/stargazers","contributors_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/contributors","subscribers_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/subscribers","subscription_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/subscription","commits_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/commits{/sha}","git_commits_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/git/commits{/sha}","comments_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/comments{/number}","issue_comment_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues/comments{/number}","contents_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/contents/{+path}","compare_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/merges","archive_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/downloads","issues_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues{/number}","pulls_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls{/number}","milestones_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/milestones{/number}","notifications_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/labels{/name}","releases_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/releases{/id}","deployments_url":"https://api.github.com/repos/TUM-LRR/era-gp-sim/deployments","created_at":"2016-04-14T17:32:54Z","updated_at":"2016-10-23T22:36:58Z","pushed_at":"2016-12-01T18:04:45Z","git_url":"git://github.com/TUM-LRR/era-gp-sim.git","ssh_url":"git@github.com:TUM-LRR/era-gp-sim.git","clone_url":"https://github.com/TUM-LRR/era-gp-sim.git","svn_url":"https://github.com/TUM-LRR/era-gp-sim","homepage":null,"size":4737,"stargazers_count":11,"watchers_count":11,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":52,"forks":2,"open_issues":52,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/164"},"html":{"href":"https://github.com/TUM-LRR/era-gp-sim/pull/164"},"issue":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues/164"},"comments":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/issues/164/comments"},"review_comments":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/164/comments"},"review_comment":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/pulls/164/commits"},"statuses":{"href":"https://api.github.com/repos/TUM-LRR/era-gp-sim/statuses/76e744ddc808df29303dcc27a30cb90e1d9292e9"}}}}
{"actor":{"display_login":"goldsborough"}}