BioDynaMo  v1.05.120-25dc9790
git_tracker.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifdef USE_LIBGIT2
16 #ifndef GIT_TRACKER_H_
17 #define GIT_TRACKER_H_
18 
19 #include <iostream>
20 #include <string>
21 
22 namespace bdm {
23 
26 class GitTracker {
27  public:
28  GitTracker() { ConstructFolderNames(); };
29  explicit GitTracker(const std::string& simulation_output) : GitTracker() {
30  simulation_output_ = GetAbsolutePath(simulation_output);
31  }
32  ~GitTracker() = default;
33 
37  void SaveGitDetails();
38 
42  void SaveGitInfo(const std::string& file,
43  const std::string& repository_path) const;
44 
48  void PrintGitInfo(const std::string& repository_path,
49  std::ostream& out = std::cout) const;
50 
54  void SaveGitDiff(const std::string& file,
55  const std::string& repository_path) const;
56 
58  void SetBdmInstallation(const std::string& path) {
59  bdm_installation_ = GetAbsolutePath(path);
60  }
61 
63  void SetSimulationOutput(const std::string& path) {
64  simulation_output_ = GetAbsolutePath(path);
65  }
66 
69  void SetCwd(const std::string& path) { cwd_ = GetAbsolutePath(path); }
70 
71  private:
73  std::string GetAbsolutePath(const std::string& path) const;
74 
76  void ConstructFolderNames();
77 
79  std::string bdm_installation_ = "";
81  std::string simulation_output_ = "";
83  std::string cwd_ = "";
84 };
85 
86 } // namespace bdm
87 
88 #endif // GIT_TRACKER_H_
89 #endif // USE_LIBGIT2
bdm
Definition: agent.cc:39