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  Project(const UUID &uu);
31  ProjectBlock &get_top_block();
32  const ProjectBlock &get_top_block() const;
33 
34  std::string create(const std::map<std::string, std::string> &meta, const UUID &default_via);
35 
36  std::string base_path;
37  UUID uuid;
38  std::map<UUID, ProjectBlock> blocks;
39 
40  UUID pool_uuid;
41  std::string vias_directory;
42  std::string pictures_directory;
43  std::string board_filename;
44  std::string pool_cache_directory;
45 
46  FileVersion version;
47 
48  json serialize() const;
49 
50 private:
51  std::string title_old;
52  std::string name_old;
53 };
54 } // namespace horizon
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61