8#include "nlohmann/json.hpp"
10#define PRODUCT_LOADER_FUN(TYPE) \
11 [](std::string file) -> std::shared_ptr<Product> \
13 std::shared_ptr<TYPE> product = std::make_shared<TYPE>(); \
14 product->load(file); \
36 nlohmann::json contents;
39 std::string instrument_name;
44 Product(Product
const &) =
delete;
45 void operator=(Product
const &x) =
delete;
100 std::string
get_product_id() {
return contents[
"product_id"].get<std::string>(); }
103 bool d_use_preset_cache =
false;
111 virtual void save(std::string directory);
117 virtual void load(std::string file);
126 std::shared_ptr<Product> loadProduct(std::string path);
134 std::function<std::shared_ptr<Product>(std::string)> loadFromFile;
141 extern std::map<std::string, RegisteredProduct> product_loaders;
149 std::map<std::string, RegisteredProduct> &product_loaders;
157 void registerProducts();
virtual void save(std::string directory)
Save the product. Depending on the type this will save a product.cbor and other files in the same dir...
Definition product.cpp:16
double get_product_timestamp()
Get the product timestamp.
Definition product.h:64
bool has_product_id()
Check if a product ID is present.
Definition product.h:94
void set_product_source(std::string source)
Set product source, optional. This is meant to contextualize where this product is from,...
Definition product.h:70
void set_product_timestamp(double timestamp)
Set product timestamp, optional. This is usually the rough creation time / acquisition time.
Definition product.h:52
bool has_product_source()
Check if a product source is present.
Definition product.h:76
std::string get_product_id()
Get the product ID.
Definition product.h:100
virtual void load(std::string file)
Load the product. This should refer to the product.cbor file.
Definition product.cpp:28
void set_product_id(std::string id)
Set product ID, optional. This is meant to, for example, differentiate several identical instruments.
Definition product.h:88
std::string get_product_source()
Get the product source.
Definition product.h:82
bool has_product_timestamp()
Check if a product timestamp is present.
Definition product.h:58
Event to subscribe to in plugins to insert new product loaders.
Definition product.h:148
Struct holding functions related to products.
Definition product.h:133