Horizon
Loading...
Searching...
No Matches
pool_parametric.hpp
1#pragma once
2#include "util/sqlite.hpp"
3#include <map>
4#include <vector>
5#include "nlohmann/json_fwd.hpp"
6
7namespace horizon {
8using json = nlohmann::json;
9
11public:
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
47private:
48 std::string base_path;
49 std::map<std::string, Table> tables;
50 bool has_table(const std::string &table);
51
52 static bool check_identifier(const std::string &s);
53};
54} // namespace horizon
Definition pool_parametric.hpp:14
Definition pool_parametric.hpp:33
Definition pool_parametric.hpp:10
Definition sqlite.hpp:72
a class to store JSON values
Definition json.hpp:177
basic_json<> json
default JSON class
Definition json_fwd.hpp:62