Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
Readparameters Class Reference

#include <readparameters.h>

Public Member Functions

 Readparameters (int cmdargc, char *cmdargv[])
 ~Readparameters ()

Static Public Member Functions

static void add (const std::string &name, const std::string &desc, const std::string &defValue)
template<typename T>
static void add (const std::string &name, const std::string &desc, const T &defValue)
static void get (const std::string &name, std::string &value)
static void get (const std::string &name, std::vector< std::string > &value)
template<typename T>
static void get (const std::string &name, T &value)
template<typename T>
static void get (const std::string &name, std::vector< T > &value)
static bool isSet (const std::string &name)
static void addComposing (const std::string &name, const std::string &desc)
static void helpMessage ()
static bool versionMessage ()
static std::string versionInfo ()
static std::string configInfo ()
static bool parse (const bool needsRunConfig=true, const bool allowUnknown=true)

Static Public Attributes

static bool helpRequested = false

Static Private Member Functions

static void addDefaultParameters ()

Static Private Attributes

static int argc
static char ** argv
static boost::program_options::options_description * descriptions = NULL
static boost::program_options::variables_map * variables = NULL
static std::map< std::string, std::string > options
static std::map< std::string, bool > isOptionParsed
static std::map< std::string, std::vector< std::string > > vectorOptions
static std::map< std::string, bool > isVectorOptionParsed
static std::string global_config_file_name = ""
static std::string user_config_file_name = ""
static std::string run_config_file_name = ""

Detailed Description

Definition at line 40 of file readparameters.h.

Constructor & Destructor Documentation

◆ Readparameters()

Readparameters::Readparameters ( int cmdargc,
char * cmdargv[] )

Constructor for class ReadParameters. The constructor defines some default parameters and parses the input files.

Parameters
cmdargcCommand line argc.
cmdargvCommand line argv.

Definition at line 51 of file readparameters.cpp.

Here is the call graph for this function:

◆ ~Readparameters()

Readparameters::~Readparameters ( )

Definition at line 73 of file readparameters.cpp.

Here is the caller graph for this function:

Member Function Documentation

◆ add() [1/2]

void Readparameters::add ( const std::string & name,
const std::string & desc,
const std::string & defValue )
inlinestatic

Add a new input parameter. Note that parse must be called in order for the input file(s) to be re-read. Only called by the root process.

Parameters
nameThe name of the parameter, as given in the input file(s).
descDescription for the parameter.
defValueDefault value for variable.

Definition at line 52 of file readparameters.h.

Here is the caller graph for this function:

◆ add() [2/2]

template<typename T>
void Readparameters::add ( const std::string & name,
const std::string & desc,
const T & defValue )
inlinestatic

Definition at line 64 of file readparameters.h.

◆ addComposing()

void Readparameters::addComposing ( const std::string & name,
const std::string & desc )
static

Add a new composing input parameter. Note that parse must be called in order for the input file(s) to be re-read. Only needs to be called by root process. It can be defined multiple times and are all returned as a vector.

Parameters
nameThe name of the parameter, as given in the input file(s).
descDescription for the parameter.

Definition at line 89 of file readparameters.cpp.

Here is the caller graph for this function:

◆ addDefaultParameters()

void Readparameters::addDefaultParameters ( )
staticprivate

Definition at line 329 of file readparameters.cpp.

Here is the caller graph for this function:

◆ configInfo()

std::string Readparameters::configInfo ( )
static

Helper wrapper function to get the config info

Returns
std string with the config information

Definition at line 143 of file readparameters.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [1/4]

void Readparameters::get ( const std::string & name,
std::string & value )
inlinestatic

Get the value of the given parameter added with add(). This may be called after having called Parse, and it may be called by any process, in any order. Aborts if given parameter was not found (a parameter passed to get() wasn't add()ed, defaults are ok).

Parameters
nameThe name of the parameter.
valueA variable where the value of the parameter is written.

Definition at line 90 of file readparameters.h.

Here is the caller graph for this function:

◆ get() [2/4]

void Readparameters::get ( const std::string & name,
std::vector< std::string > & value )
inlinestatic

Definition at line 103 of file readparameters.h.

◆ get() [3/4]

template<typename T>
void Readparameters::get ( const std::string & name,
std::vector< T > & value )
inlinestatic

Get the value of the given parameter added with addComposing(). This may be called after having called Parse, and it may be called by any process, in any order. Aborts on failed cast.

Parameters
nameThe name of the parameter.
valueA variable where the value of the parameter is written.

Definition at line 141 of file readparameters.h.

Here is the call graph for this function:

◆ get() [4/4]

template<typename T>
void Readparameters::get ( const std::string & name,
T & value )
inlinestatic

Definition at line 116 of file readparameters.h.

Here is the call graph for this function:

◆ helpMessage()

void Readparameters::helpMessage ( )
static

Write the descriptions of known input options to standard output if an option called "help" has been read, and exit in that case.

Definition at line 102 of file readparameters.cpp.

Here is the caller graph for this function:

◆ isSet()

bool Readparameters::isSet ( const std::string & name)
inlinestatic

Definition at line 163 of file readparameters.h.

◆ parse()

bool Readparameters::parse ( const bool needsRunConfig = true,
const bool allowUnknown = true )
static

Request Parameters to reparse input file(s). This function needs to be called after new options have been added via Parameters:add functions. Otherwise the values of the new options are not read. This is a collective function, all processes have to see it.

Parameters
needsRunConfigWhether or not this program can run without a runconfig file (esm: vlasiator can't, but particle pusher can).
allowUnknowntrue if unregistered options are parsed without error.
Returns
True if input file(s) were parsed successfully.

Definition at line 157 of file readparameters.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ versionInfo()

std::string Readparameters::versionInfo ( )
static

Helper wrapper function to get version info

Returns
std string with the version information

Definition at line 136 of file readparameters.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ versionMessage()

bool Readparameters::versionMessage ( )
static

Write version information to standard output if an option called "version" has been read.

Returns
If true, option called "version" was found and descriptions were written to standard output.

Definition at line 119 of file readparameters.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ argc

int Readparameters::argc
staticprivate

How many entries argv contains.

Definition at line 182 of file readparameters.h.

◆ argv

char ** Readparameters::argv
staticprivate

Pointer to char* array containing command line parameters.

Definition at line 183 of file readparameters.h.

◆ descriptions

PO::options_description * Readparameters::descriptions = NULL
staticprivate

Definition at line 185 of file readparameters.h.

◆ global_config_file_name

string Readparameters::global_config_file_name = ""
staticprivate

Definition at line 193 of file readparameters.h.

◆ helpRequested

bool Readparameters::helpRequested = false
static

Definition at line 179 of file readparameters.h.

◆ isOptionParsed

map< string, bool > Readparameters::isOptionParsed
staticprivate

Definition at line 189 of file readparameters.h.

◆ isVectorOptionParsed

map< string, bool > Readparameters::isVectorOptionParsed
staticprivate

Definition at line 191 of file readparameters.h.

◆ options

map< string, string > Readparameters::options
staticprivate

Definition at line 188 of file readparameters.h.

◆ run_config_file_name

string Readparameters::run_config_file_name = ""
staticprivate

Definition at line 195 of file readparameters.h.

◆ user_config_file_name

string Readparameters::user_config_file_name = ""
staticprivate

Definition at line 194 of file readparameters.h.

◆ variables

PO::variables_map * Readparameters::variables = NULL
staticprivate

Definition at line 186 of file readparameters.h.

◆ vectorOptions

map< string, vector< string > > Readparameters::vectorOptions
staticprivate

Definition at line 190 of file readparameters.h.


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