Horizon
stock_info_provider_digikey.hpp
1 #pragma once
2 #include "stock_info_provider.hpp"
3 #include "http_client.hpp"
4 #include <condition_variable>
5 #include <mutex>
6 #include <thread>
7 #include "nlohmann/json_fwd.hpp"
8 #include "pool/pool.hpp"
9 
10 namespace horizon {
11 namespace SQLite {
12 class Database;
13 }
14 
15 using json = nlohmann::json;
16 
18 public:
19  StockInfoProviderDigiKey(const std::string &pool_base_path);
20  void add_columns(Gtk::TreeView *treeview, Gtk::TreeModelColumn<std::shared_ptr<StockInfoRecord>> column) override;
21  void update_parts(const std::list<UUID> &parts) override;
22  std::list<std::shared_ptr<StockInfoRecord>> get_records() override;
23  Gtk::Widget *create_status_widget() override;
25  static void init_db();
26  static std::string get_db_filename();
27  static std::string update_tokens_from_response(SQLite::Database &db, const json &j);
28  static bool is_valid();
29  static void cleanup();
30 
31 private:
32  class StockInfoProviderDigiKeyWorker *worker = nullptr;
33  class StockInfoProviderDigiKeyFetchWorker *fetch_worker = nullptr;
34  Gtk::Label *status_label = nullptr;
35  Gtk::Popover popover;
36 
37  void handle_click(GdkEventButton *ev);
38  void construct_popover(const class StockInfoRecordDigiKey &rec);
39  Gtk::TreeView *treeview = nullptr;
40  Gtk::TreeViewColumn *tvc = nullptr;
41  Gtk::TreeModelColumn<std::shared_ptr<StockInfoRecord>> column;
42 };
43 } // namespace horizon
Definition: sqlite.hpp:69
Definition: stock_info_provider_digikey.cpp:262
Definition: stock_info_provider_digikey.hpp:17
Definition: stock_info_provider.hpp:20
Definition: stock_info_provider_digikey.cpp:224
a class to store JSON values
Definition: json.hpp:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62