SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
product_handler.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "../handler.h"
9#include "common/widgets/markdown_helper.h"
10#include "nlohmann/json.hpp"
11#include "products/product.h"
12#include <functional>
13#include <memory>
14#include <vector>
15
16namespace satdump
17{
18 namespace handlers
19 {
32 class ProductHandler : public Handler, public ProcessingHandler
33 {
34 private:
35 std::string handler_name;
36
37 std::string preset_search_str;
38 std::vector<nlohmann::json> all_presets;
39 std::vector<std::string> preset_selection_box_str;
40 int preset_selection_curr_id = -1;
41
42 bool has_markdown_description = false;
43 bool show_markdown_description = false;
44 widgets::MarkdownHelper markdown_info;
45
46 protected:
47 // TODOREWORK document
48 bool preset_reset_by_handler = false;
49 void resetPreset()
50 {
51 preset_selection_curr_id = -1;
52 has_markdown_description = false;
53 }
54
55 protected:
56 std::shared_ptr<products::Product> product;
57 nlohmann::ordered_json instrument_cfg;
58
59 // TODOREWORK document!
60 std::string product_internal_name; // TODOREWORK? Rename? No idea
61 std::string generateFileName();
62
63 protected:
68 bool renderPresetMenu();
69
75
76 public:
77 nlohmann::json getInstrumentCfg() { return instrument_cfg; }
78 virtual void saveResult(std::string directory);
79
80 public:
88 ProductHandler(std::shared_ptr<products::Product> p, bool dataset_mode = false, std::function<bool(nlohmann::ordered_json &)> filterPreset = [](auto &) { return true; });
89
90 std::string getName() { return handler_name; }
91
92 std::string getID() { return "product_handler"; };
93 };
94
105 {
106 std::shared_ptr<products::Product> &product;
107 std::shared_ptr<ProductHandler> &handler;
108 bool dataset_mode;
109 };
110
119 std::shared_ptr<ProductHandler> getProductHandlerForProduct(std::shared_ptr<products::Product> product, bool dataset_mode = false);
120 } // namespace handlers
121} // namespace satdump
SatDump's handler base class.
Definition handler.h:32
std::string getName()
Get this handler's readable name.
Definition product_handler.h:90
ProductHandler(std::shared_ptr< products::Product > p, bool dataset_mode=false, std::function< bool(nlohmann::ordered_json &)> filterPreset=[](auto &) { return true;})
Constructor.
Definition product_handler.cpp:17
void tryApplyDefaultPreset()
Attempts to a apply a default preset if present in the configuration.
Definition product_handler.cpp:181
bool renderPresetMenu()
Draw preset selection menu.
Definition product_handler.cpp:108
Core Product implementation.
std::shared_ptr< ProductHandler > getProductHandlerForProduct(std::shared_ptr< products::Product > product, bool dataset_mode=false)
Get the appropriate ProductHandler for the provided products.
Definition product_handler_init.cpp:14
Event used to let plugins provide additional ProductHandlers.
Definition product_handler.h:105