Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
DBManager.h
Go to the documentation of this file.
1#ifndef DBMANAGER_H
2#define DBMANAGER_H
3
4#include <memory>
5#include <filesystem>
6
7#include "DBNode.h"
8#include "ParserFactory.h"
9#include "LhaBlockPrototype.h"
10
11namespace fs = std::filesystem;
12
46class DBManager {
47private:
54 static inline const std::map<ParserFactory::Type, std::unordered_set<std::string>> EXTENSIONS {
55 {ParserFactory::Type::JSON, {".json"}},
56 {ParserFactory::Type::YAML, {".yml", ".yaml"}},
57 {ParserFactory::Type::LHA, {".lha", ".slha", ".flha"}},
58 };
59
68 static inline std::unordered_set<Prototype> lha_prototypes {};
69
80 ParserFactory::Type deduce_parser_type(fs::path file_path);
81
93 void add_default_lha_prototypes(fs::path file_path);
94
108 void sanitize_file(const fs::path& file_path);
109
124 void sanitize_tree(const std::shared_ptr<DBNode>& root, const std::vector<BlockName>& required_keys = {});
125
126public:
144 std::shared_ptr<DBNode> read_from_file(fs::path file_path);
145
164 void write_to_file(fs::path file_path, std::shared_ptr<DBNode> root);
165
186 void add_lha_prototype(BlockName blockName, size_t itemCount=2, size_t valueIdx=1, int scaleIdx=-1, int rgIdx=-1, int binIdx=-1, bool globalScale=false);
187
189};
190
191
192#endif // DBMANAGER_H
Hierarchical key–value tree with JSON/YAML serialization.
Block identifier with alias support.
Definition BlockName.h:59
Front-end for reading and writing structured data as DBNodetrees.
Definition DBManager.h:46
void add_lha_prototype(BlockName blockName, size_t itemCount=2, size_t valueIdx=1, int scaleIdx=-1, int rgIdx=-1, int binIdx=-1, bool globalScale=false)
Adds or overrides an LHA block prototype used by LhaParser.
void write_to_file(fs::path file_path, std::shared_ptr< DBNode > root)
Writes a DBNodetree to disk using the appropriate format.
Definition DBManager.cpp:92
std::shared_ptr< DBNode > read_from_file(fs::path file_path)
Reads a structured file and returns its DBNoderepresentation.
Definition DBManager.cpp:62
Central factory for building concrete IDBNodeProvider objects.