Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
DBManager Class Reference

Front-end for reading and writing structured data as DBNodetrees. More...

#include <DBManager.h>

Public Member Functions

std::shared_ptr< DBNoderead_from_file (fs::path file_path)
 Reads a structured file and returns its DBNoderepresentation.
 
void write_to_file (fs::path file_path, std::shared_ptr< DBNode > root)
 Writes a DBNodetree to disk using the appropriate format.
 
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.
 

Friends

class DBNodeProviderFactory
 

Detailed Description

Front-end for reading and writing structured data as DBNodetrees.

A DBManager instance encapsulates:

  • a static mapping between parser types and supported file extensions,
  • a static set of LHA/SLHA/FLHA block prototypes used by LhaParser,
  • helper methods to sanitize files and DBNodetrees.

Typical usage:

auto root = db.read_from_file("input.flha");
// ... work with root ...
db.write_to_file("output.yaml", root);
Front-end for reading and writing structured data as DBNodetrees.
Definition DBManager.h:46
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

Definition at line 46 of file DBManager.h.

Member Function Documentation

◆ add_lha_prototype()

void DBManager::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.

This function lets the user extend or customize the interpretation of LHA/SLHA/FLHA blocks at runtime. The block name is normalized to upper-case before insertion.

If a prototype with the same block name already exists:

  • if it is identical to new_prototype, a warning is logged and the call is ignored,
  • otherwise, a fatal error is logged (conflicting layouts).
Parameters
blockNameName of the block (case-insensitive, will be uppercased).
itemCountTotal number of columns in the block (default: 2).
valueIdxIndex of the value column (default: 1).
scaleIdxIndex of the scale column, or -1 if none (default: -1).
rgIdxIndex of the renormalization scheme column, or -1 (default: -1).
binIdxIndex of the bin lower-bound column, or -1 if unbinned (default: -1).
globalScaleTrue if the block uses a global Q= scale in the header.

Definition at line 100 of file DBManager.cpp.

◆ read_from_file()

std::shared_ptr< DBNode > DBManager::read_from_file ( fs::path  file_path)

Reads a structured file and returns its DBNoderepresentation.

The pipeline is:

  • sanitize_file(file_path),
  • deduce_parser_type(file_path),
  • create an appropriate parser via ParserFactory,
  • for LHA files: add default LHA prototypes and configure LhaParser,
  • parser->readFromFile(file_path),
  • sanitize_tree(root).
Parameters
file_pathPath to the file to be read.
Returns
Shared pointer to the root DBNode.
Exceptions
std::runtime_errorfor file errors, parser errors, or tree validation errors.

Definition at line 62 of file DBManager.cpp.

◆ write_to_file()

void DBManager::write_to_file ( fs::path  file_path,
std::shared_ptr< DBNode root 
)

Writes a DBNodetree to disk using the appropriate format.

The pipeline is:

  • sanitize_tree(root, {"SMINPUTS"}) to ensure minimal consistency,
  • deduce_parser_type(file_path),
  • create an appropriate parser,
  • parser->writeToFile(file_path, root),
  • sanitize_file(file_path) to validate the written file.

Note: requiring "SMINPUTS" is domain-specific and encodes the expectation that any physical input set at least carries this block.

Parameters
file_pathPath where the file should be written.
rootRoot DBNodeto serialize.
Exceptions
std::runtime_errorif validation fails or writing fails.

Definition at line 92 of file DBManager.cpp.

Friends And Related Symbol Documentation

◆ DBNodeProviderFactory

friend class DBNodeProviderFactory
friend

Definition at line 188 of file DBManager.h.


The documentation for this class was generated from the following files: