ConfigurationHelper Class Reference#

DiFfRG: DiFfRG::ConfigurationHelper Class Reference
DiFfRG
Discretization Framework for functional Renormalization Group flows

Class to read parameters given from the command line and from a parameter file. More...

#include <configuration_helper.hh>

Public Member Functions

 ConfigurationHelper (int argc, char *argv[], const std::string parameter_file="parameter.json")
 Construct a new Configuration Helper object To get an overview of the available arguments, just pass –help as an argument.
 
 ConfigurationHelper (const ConfigurationHelper &)
 Copy a Configuration Helper.
 
 ConfigurationHelper (const ConfigTree &config)
 Construct a new Configuration Helper object from a ConfigTree object.
 
void append (std::string arg)
 Add a CLI-like argument to the list of arguments.
 
ConfigTree & get_config ()
 Obtain the configuration tree containing all the parameters.
 
const ConfigTree & get_config () const
 Obtain the configuration tree containing all the parameters.
 
ConfigTree & get_json ()
 Obtain the configuration tree containing all the parameters.
 
const ConfigTree & get_json () const
 Obtain the configuration tree containing all the parameters.
 
std::string get_log_file () const
 
std::string get_parameter_file () const
 
std::string get_output_name () const
 
std::string get_output_folder () const
 
std::string get_top_folder () const
 

Static Public Member Functions

static ConfigTree probe (int argc, char *argv[], const std::string parameter_file="parameter.json")
 Read the configuration without producing any diagnostics or terminating.
 

Private Member Functions

 ConfigurationHelper ()=default
 
void parse ()
 
void parse_cli ()
 
void print_usage_message ()
 
void generate_parameter_file ()
 

Private Attributes

std::list< std::string > args
 
std::list< std::pair< std::string, std::string > > cli_parameters
 
ConfigTree config
 
bool parsed = false
 
std::string parameter_file
 
bool parameter_file_explicit = false
 
bool quiet = false
 

Detailed Description

Class to read parameters given from the command line and from a parameter file.

Constructor & Destructor Documentation

◆ ConfigurationHelper() [1/4]

DiFfRG::ConfigurationHelper::ConfigurationHelper ( int argc,
char * argv[],
const std::string parameter_file = "parameter.json" )

Construct a new Configuration Helper object To get an overview of the available arguments, just pass –help as an argument.

Parameters
argcForwarded argc from main() function
argvForwarded argv from main() function
parameter_fileThe name of the parameter file to be read. If this default name does not exist on disk, but the same name with a ".toml" extension does, the latter is read instead. A file given explicitly with the -p flag is never substituted.

◆ ConfigurationHelper() [2/4]

DiFfRG::ConfigurationHelper::ConfigurationHelper ( const ConfigurationHelper & )

Copy a Configuration Helper.

◆ ConfigurationHelper() [3/4]

DiFfRG::ConfigurationHelper::ConfigurationHelper ( const ConfigTree & config)

Construct a new Configuration Helper object from a ConfigTree object.

◆ ConfigurationHelper() [4/4]

DiFfRG::ConfigurationHelper::ConfigurationHelper ( )
privatedefault

Member Function Documentation

◆ append()

void DiFfRG::ConfigurationHelper::append ( std::string arg)

Add a CLI-like argument to the list of arguments.

◆ generate_parameter_file()

void DiFfRG::ConfigurationHelper::generate_parameter_file ( )
private

◆ get_config() [1/2]

ConfigTree & DiFfRG::ConfigurationHelper::get_config ( )

Obtain the configuration tree containing all the parameters.

◆ get_config() [2/2]

const ConfigTree & DiFfRG::ConfigurationHelper::get_config ( ) const

Obtain the configuration tree containing all the parameters.

◆ get_json() [1/2]

ConfigTree & DiFfRG::ConfigurationHelper::get_json ( )

Obtain the configuration tree containing all the parameters.

Kept as the historical spelling of get_config().

◆ get_json() [2/2]

const ConfigTree & DiFfRG::ConfigurationHelper::get_json ( ) const

Obtain the configuration tree containing all the parameters.

Kept as the historical spelling of get_config().

◆ get_log_file()

std::string DiFfRG::ConfigurationHelper::get_log_file ( ) const

◆ get_output_folder()

std::string DiFfRG::ConfigurationHelper::get_output_folder ( ) const

◆ get_output_name()

std::string DiFfRG::ConfigurationHelper::get_output_name ( ) const

◆ get_parameter_file()

std::string DiFfRG::ConfigurationHelper::get_parameter_file ( ) const

◆ get_top_folder()

std::string DiFfRG::ConfigurationHelper::get_top_folder ( ) const

◆ parse()

void DiFfRG::ConfigurationHelper::parse ( )
private

◆ parse_cli()

void DiFfRG::ConfigurationHelper::parse_cli ( )
private

◆ print_usage_message()

void DiFfRG::ConfigurationHelper::print_usage_message ( )
private

◆ probe()

static ConfigTree DiFfRG::ConfigurationHelper::probe ( int argc,
char * argv[],
const std::string parameter_file = "parameter.json" )
static

Read the configuration without producing any diagnostics or terminating.

Behaves like the (argc, argv, parameter_file) constructor - same -p handling, same TOML fallback, same -sd/-si/-sb/-ss overrides - but never prints a usage message, never warns about unknown arguments and never calls exit(). Errors yield an empty tree instead.

This exists so that DiFfRG::Init can look at a few parameters (notably /discretization/threads) before the libraries are brought up, while leaving the authoritative, diagnostics-producing parse to the application itself.

Member Data Documentation

◆ args

std::list<std::string> DiFfRG::ConfigurationHelper::args
private

◆ cli_parameters

std::list<std::pair<std::string, std::string> > DiFfRG::ConfigurationHelper::cli_parameters
private

◆ config

ConfigTree DiFfRG::ConfigurationHelper::config
private

◆ parameter_file

std::string DiFfRG::ConfigurationHelper::parameter_file
private

◆ parameter_file_explicit

bool DiFfRG::ConfigurationHelper::parameter_file_explicit = false
private

Whether parameter_file was named explicitly with -p, which disables the fallback to a TOML file of the same name.

◆ parsed

bool DiFfRG::ConfigurationHelper::parsed = false
private

◆ quiet

bool DiFfRG::ConfigurationHelper::quiet = false
private

In quiet mode nothing is printed and nothing exits the process; failures are thrown instead. Set by probe(). See probe() for why.


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