Horizon
pool_parametric.hpp
1 #pragma once
2 #include "util/sqlite.hpp"
3 #include <map>
4 #include <vector>
5 #include "nlohmann/json_fwd.hpp"
6 
7 namespace horizon {
8 using json = nlohmann::json;
9 
11 public:
12  PoolParametric(const std::string &base_path, bool read_only = true);
13 
14  class Column {
15  public:
16  Column();
17  Column(const json &j);
18  std::string name;
19  std::string display_name;
20  enum class Type { QUANTITY, STRING, ENUM };
21  Type type = Type::STRING;
22  std::string unit;
23  bool use_si = true;
24  bool no_milli = false;
25  int digits = -1;
26  std::vector<std::string> enum_items;
27  bool required = true;
28 
29  std::string format(const std::string &v) const;
30  std::string format(double v) const;
31  };
32 
33  class Table {
34  public:
35  Table(const std::string &name, const json &j);
36  std::string name;
37  std::string display_name;
38  std::vector<Column> columns;
39  };
40 
41  const std::string &get_base_path() const;
42  const std::map<std::string, Table> &get_tables() const;
43  static const std::vector<Column> &get_extra_columns();
44 
46 
47 private:
48  std::string base_path;
49  std::map<std::string, Table> tables;
50  bool has_table(const std::string &table);
51 };
52 } // namespace horizon
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::PoolParametric::Table
Definition: pool_parametric.hpp:33
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:161
horizon::PoolParametric::Column
Definition: pool_parametric.hpp:14
SQLite::Database
Definition: sqlite.hpp:63
horizon::PoolParametric
Definition: pool_parametric.hpp:10