Horizon
pool_updater.hpp
1 #pragma once
2 #include "pool-update.hpp"
3 #include "util/sqlite.hpp"
4 #include "pool-update_pool.hpp"
5 #include "graph.hpp"
6 #include <filesystem>
7 
8 namespace horizon {
9 class PoolUpdater {
10 public:
11  PoolUpdater(const std::string &bp, pool_update_cb_t status_cb);
12  void update();
13  void update_some(const std::vector<std::string> &filenames, std::set<UUID> &all_parts_updated);
14 
15  PoolUpdatePool &get_pool()
16  {
17  return *pool;
18  }
19 
20  bool was_partial_update() const
21  {
22  return is_partial_update;
23  }
24 
26  public:
27  };
28 
29 private:
30  std::optional<PoolUpdatePool> pool;
31  std::optional<SQLite::Query> q_exists;
32  std::optional<SQLite::Query> q_exists_by_filename;
33  std::optional<SQLite::Query> q_add_dependency;
34  std::optional<SQLite::Query> q_insert_part;
35  std::optional<SQLite::Query> q_add_tag;
36 
37 
38  std::string base_path;
39  pool_update_cb_t status_cb;
40  void update_frames(const std::string &directory, const std::string &prefix = "");
41  void update_decals(const std::string &directory, const std::string &prefix = "");
42  void update_units(const std::string &directory, const std::string &prefix = "");
43  void update_entities(const std::string &directory, const std::string &prefix = "");
44  void update_symbols(const std::string &directory, const std::string &prefix = "");
45  void add_padstack(const Padstack &padstack, const UUID &pkg_uuid, const UUID &last_pool_uuid,
46  const std::string &filename, const std::string &filename_abs);
47  void update_padstacks(const std::string &directory, const std::string &prefix = "");
48  void update_padstacks_global(const std::string &directory, const std::string &prefix = "");
49  void update_packages(const std::string &directory);
50  void update_package_node(const PoolUpdateNode &node, std::set<UUID> &visited);
51  void update_parts(const std::string &directory);
52  void update_part_node(const PoolUpdateNode &node, std::set<UUID> &visited);
53  void add_dependency(ObjectType type, const UUID &uu, ObjectType dep_type, const UUID &dep_uuid);
54  void add_tag(ObjectType type, const UUID &uu, const std::string &tag);
55  void clear_dependencies(ObjectType type, const UUID &uu);
56  void clear_tags(ObjectType type, const UUID &uu);
57  std::optional<std::pair<UUID, UUID>> exists(ObjectType type, const UUID &uu);
58  void delete_item(ObjectType type, const UUID &uu);
59  std::optional<UUID> handle_override(ObjectType type, const UUID &u, const std::string &filename);
60 
61  void update_frame(const std::string &filename);
62  void update_decal(const std::string &filename);
63  bool update_part(const std::string &filename);
64  void update_unit(const std::string &filename);
65  void update_symbol(const std::string &filename);
66  void update_entity(const std::string &filename);
67  void update_package(const std::string &filename);
68  void update_padstack(const std::string &filename);
69 
70  void part_add_dir_to_graph(PoolUpdateGraph &graph, const std::string &directory);
71  std::map<std::string, json> json_cache;
72  const json &load_json(const std::string &filename);
73 
74  UUID pool_uuid;
75  bool is_partial_update = false;
76  void set_pool_info(const std::string &bp);
77  std::string get_path_rel(const std::string &filename) const;
78 
79  std::vector<std::string> update_included_pools();
80 
81  static std::filesystem::file_time_type::duration::rep get_mtime(const std::string &filename);
82 };
83 } // namespace horizon
Definition: padstack.hpp:19
Definition: graph.hpp:23
Definition: graph.hpp:10
Definition: pool-update_pool.hpp:5
Definition: pool_updater.hpp:9
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:177