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