Horizon
project.hpp
1 #pragma once
2 #include "util/uuid.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include <map>
5 #include <deque>
6 #include "util/file_version.hpp"
7 
8 namespace horizon {
9 using json = nlohmann::json;
10 
11 class ProjectBlock {
12 public:
13  ProjectBlock(const UUID &uu, const std::string &b, const std::string &s, bool t = false)
14  : uuid(uu), block_filename(b), schematic_filename(s), is_top(t)
15  {
16  }
17  UUID uuid;
18  std::string block_filename;
19  std::string schematic_filename;
20  bool is_top;
21 };
22 
23 class Project {
24 private:
25  Project(const UUID &uu, const json &, const std::string &base);
26  std::string get_filename_rel(const std::string &p) const;
27 
28 public:
29  static Project new_from_file(const std::string &filename);
30  static unsigned int get_app_version();
31  Project(const UUID &uu);
32  ProjectBlock &get_top_block();
33  const ProjectBlock &get_top_block() const;
34 
35  std::string create(const std::map<std::string, std::string> &meta, const UUID &pool_uuid, const UUID &default_via);
36 
37  static bool gitignore_needs_fixing(const std::string &filename);
38  static void fix_gitignore(const std::string &filename);
39 
40  std::string base_path;
41  UUID uuid;
42  std::map<UUID, ProjectBlock> blocks;
43 
44  std::string pictures_directory;
45  std::string board_filename;
46  std::string pool_directory;
47 
48  FileVersion version;
49 
50  json serialize() const;
51 
52 private:
53  std::string title_old;
54  std::string name_old;
55  std::string vias_directory_old;
56 
57  UUID pool_uuid_old;
58  std::string pool_cache_directory_old;
59 };
60 } // namespace horizon
Definition: file_version.hpp:8
Definition: project.hpp:11
Definition: project.hpp:23
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
a class to store JSON values
Definition: json.hpp:170
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62