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(const std::vector<std::string> &base_paths);
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 private:
21  std::optional<PoolUpdatePool> pool;
22  std::optional<SQLite::Query> q_exists;
23  std::optional<SQLite::Query> q_add_dependency;
24  std::optional<SQLite::Query> q_insert_part;
25  std::optional<SQLite::Query> q_add_tag;
26 
27 
28  std::string base_path;
29  pool_update_cb_t status_cb;
30  void update_frames(const std::string &directory, const std::string &prefix = "");
31  void update_decals(const std::string &directory, const std::string &prefix = "");
32  void update_units(const std::string &directory, const std::string &prefix = "");
33  void update_entities(const std::string &directory, const std::string &prefix = "");
34  void update_symbols(const std::string &directory, const std::string &prefix = "");
35  void add_padstack(const Padstack &padstack, const UUID &pkg_uuid, const UUID &last_pool_uuid,
36  const std::string &filename, const std::string &filename_abs);
37  void update_padstacks(const std::string &directory, const std::string &prefix = "");
38  void update_padstacks_global(const std::string &directory, const std::string &prefix = "");
39  void update_packages(const std::string &directory);
40  void update_package_node(const PoolUpdateNode &node, std::set<UUID> &visited);
41  void update_parts(const std::string &directory);
42  void update_part_node(const PoolUpdateNode &node, std::set<UUID> &visited);
43  void add_dependency(ObjectType type, const UUID &uu, ObjectType dep_type, const UUID &dep_uuid);
44  void add_tag(ObjectType type, const UUID &uu, const std::string &tag);
45  void clear_dependencies(ObjectType type, const UUID &uu);
46  void clear_tags(ObjectType type, const UUID &uu);
47  std::optional<std::pair<UUID, UUID>> exists(ObjectType type, const UUID &uu);
48  void delete_item(ObjectType type, const UUID &uu);
49  std::optional<UUID> handle_override(ObjectType type, const UUID &u);
50 
51  void update_frame(const std::string &filename);
52  void update_decal(const std::string &filename);
53  bool update_part(const std::string &filename);
54  void update_unit(const std::string &filename);
55  void update_symbol(const std::string &filename);
56  void update_entity(const std::string &filename);
57  void update_package(const std::string &filename);
58  void update_padstack(const std::string &filename);
59 
60  void part_add_dir_to_graph(PoolUpdateGraph &graph, const std::string &directory);
61  std::map<std::string, json> json_cache;
62  const json &load_json(const std::string &filename);
63 
64  UUID pool_uuid;
65  bool is_partial_update = false;
66  void set_pool_info(const std::string &bp);
67  std::string get_path_rel(const std::string &filename) const;
68 
69  static std::filesystem::file_time_type::duration::rep get_mtime(const std::string &filename);
70 };
71 } // namespace horizon
Definition: padstack.hpp:21
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