CEPS  24.01
Cardiac ElectroPhysiology Simulator
InputParameters Class Reference

Detailed Description

Reads and stores simulation configuration.

This class reads and stores parameters key: value <additional value ...>

Only lines with the colon (:) character will be considered as parameters lines. All other lines are commentary.

keys and values will be trimmed from any white spaces.

If the line ends with a backslash character (), options can be continued on the next line

For compatibility with old CEPS input file, a key can be given several times. The value CepsString will be appended to the previous lines with a comma separator.

There is no type management in this class anymore, nor in the input file. This is up to the calling class to do this, with the getReal, getString, getInt functions.

Finally, for compatibility with old ceps files, std::strings with double quotes will have the quotes removed. This removes the possibility of using double quotes in std::strings for new input files, but the 'damage' should not be problematic. CAN BE DISCUSSED.

Definition at line 70 of file InputParameters.hpp.

#include <InputParameters.hpp>

Inheritance diagram for InputParameters:
[legend]

Public Member Functions

 InputParameters ()
 Empty constructor. More...
 
 InputParameters (const CepsString &inputFile, CepsBool warnDefault=false)
 Constructor with file name. More...
 
 InputParameters (const InputParameters &that)=default
 Copy constructor. More...
 
InputParametersoperator= (const InputParameters &that)=default
 Assignment operator. More...
 
 ~InputParameters () override
 Destructor. More...
 
void read ()
 Reads all available parameters in specified file. More...
 
CepsReal getReal (const keyType &key) const
 Reads a floating point value from configuration. More...
 
CepsMathVertex getMathVertex (const keyType &key) const
 Reads 3 floating point values from configuration. More...
 
CepsInt getInt (const keyType &key) const
 Reads an integer value from configuration. More...
 
CepsString getString (const keyType &key) const
 Reads a CepsString from configuration. More...
 
CepsString operator() (const keyType &key) const
 Reads a CepsString from configuration. More...
 
CepsReal getReal (const keyType &key, const CepsReal &dval) const
 Reads a floating point value from configuration. More...
 
CepsMathVertex getMathVertex (const keyType &key, const CepsMathVertex &dval) const
 Reads 3 floating point values from configuration. More...
 
CepsInt getInt (const keyType &key, const CepsInt &dval) const
 Reads an integer value from configuration. More...
 
CepsString getString (const keyType &key, const CepsString &dval) const
 Reads a CepsString from configuration. More...
 
CepsString operator() (const keyType &key, const CepsString &dval) const
 Reads a CepsString from configuration. More...
 
void set (const keyType &key, const CepsString &value)
 Adds or modifies an entry in the configuration. More...
 
void set (const keyType &key, const CepsReal &value)
 Adds or modifies an entry in the configuration. More...
 
void set (const keyType &key, const CepsInt &value)
 Adds or modifies an entry in the configuration. More...
 
void erase (const keyType &key)
 Removes an entry in the configuration. More...
 
CepsBool hasKey (const keyType &key) const
 Tells if key exists in input file. More...
 
CepsBool isActiveOption (const keyType &key) const
 Tells if key exists in configuration and is of "1","YES","ON" or "TRUE". More...
 
CepsBool isInactiveOption (const keyType &key) const
 Tells if key exists in configuration and is of "0","NO","OFF" or "FALSE". More...
 
- Public Member Functions inherited from FileReader
 FileReader ()
 Alternative constructor. More...
 
 FileReader (const CepsString &fileName)
 Default constructor. More...
 
 FileReader (const FileReader &that)
 Copy constructor. More...
 
FileReaderoperator= (const FileReader &that)
 Copy constructor. More...
 
virtual ~FileReader ()
 Destructor. Calls FileReader::close. More...
 
void setFileName (const CepsString &fileName)
 Set file to read. More...
 
virtual CepsBool open ()
 Opens the designated file in read mode. More...
 
virtual void close ()
 Close the file. More...
 
virtual CepsBool good ()
 true if stream is still readable More...
 
void reset ()
 Set file stream to the beginning of the file. More...
 
CepsUInt find (const CepsString &pattern)
 Advance stream until pattern is found. More...
 
CepsBool findNext (const CepsString &pattern)
 Advance stream until pattern is found. More...
 
CepsUInt findNextOf (const CepsVector< CepsString > &patterns)
 Advance stream until one of patterns is found. More...
 
CepsString getFileName ()
 Name of parsed file. More...
 
CepsUInt skipLines (CepsUInt nbLines)
 Skip given number of lines. More...
 
void oneLine (CepsString &line)
 Get one line from the stream. More...
 
template<typename T >
FileReaderoperator>> (T &var)
 Reading operator. More...
 
CepsInt lineIndex (const CepsString &word)
 Index of first line starting with word, search starting from the current stream position. More...
 
CepsUInt checkEOF ()
 Checks if the reader reached end of file. More...
 

Protected Member Functions

void errIfNoKey (const keyType &key, const CepsString &type) const
 Prints an error message if file misses a key. More...
 
void warnNoKey (const keyType &key, const CepsString &defValue, const CepsString &type) const
 Prints an warning message if file misses a key and use the default value. More...
 

Private Types

using keyType = CepsString
 

Private Attributes

CepsMap< keyType, CepsStringm_keyVals
 The parameters stored as std::strings. More...
 
CepsBool m_warnDefault
 Print missing values warnings if true. More...
 

Additional Inherited Members

- Protected Attributes inherited from FileReader
CepsString m_fileName
 file to open More...
 
std::ifstream m_file
 stream More...
 

Member Typedef Documentation

◆ keyType

Definition at line 73 of file InputParameters.hpp.

Constructor & Destructor Documentation

◆ InputParameters() [1/3]

InputParameters::InputParameters ( )

Empty constructor.

Definition at line 42 of file InputParameters.cpp.

◆ InputParameters() [2/3]

InputParameters::InputParameters ( const CepsString inputFile,
CepsBool  warnDefault = false 
)
explicit

Constructor with file name.

Parameters
[in]inputFileCan be absolute or relative file name
[in]warnDefaultPrint messages for using default values when a key is missing

Definition at line 47 of file InputParameters.cpp.

◆ InputParameters() [3/3]

InputParameters::InputParameters ( const InputParameters that)
default

Copy constructor.

◆ ~InputParameters()

InputParameters::~InputParameters ( )
override

Destructor.

Definition at line 55 of file InputParameters.cpp.

Member Function Documentation

◆ erase()

void InputParameters::erase ( const keyType key)

Removes an entry in the configuration.

Definition at line 291 of file InputParameters.cpp.

◆ errIfNoKey()

void InputParameters::errIfNoKey ( const keyType key,
const CepsString type 
) const
protected

Prints an error message if file misses a key.

Parameters
[in]keyThe missing key. :(
[in]typeexpected type of value

Definition at line 253 of file InputParameters.cpp.

◆ getInt() [1/2]

CepsInt InputParameters::getInt ( const keyType key) const

Reads an integer value from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.

Interrupts the program if key is not provided.

Definition at line 179 of file InputParameters.cpp.

◆ getInt() [2/2]

CepsInt InputParameters::getInt ( const keyType key,
const CepsInt dval 
) const

Reads an integer value from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.
[in]dvalDefault value used if key is not found in config.

Definition at line 187 of file InputParameters.cpp.

◆ getMathVertex() [1/2]

CepsMathVertex InputParameters::getMathVertex ( const keyType key) const

Reads 3 floating point values from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.

Interrupts the program if key is not provided.

Definition at line 157 of file InputParameters.cpp.

◆ getMathVertex() [2/2]

CepsMathVertex InputParameters::getMathVertex ( const keyType key,
const CepsMathVertex dval 
) const

Reads 3 floating point values from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.
[in]dvalDefault value used if key is not found in config.

Definition at line 165 of file InputParameters.cpp.

◆ getReal() [1/2]

CepsReal InputParameters::getReal ( const keyType key) const

Reads a floating point value from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.

Interrupts the program if key is not provided.

Definition at line 137 of file InputParameters.cpp.

◆ getReal() [2/2]

CepsReal InputParameters::getReal ( const keyType key,
const CepsReal dval 
) const

Reads a floating point value from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.
[in]dvalDefault value used if key is not found in config.

Definition at line 145 of file InputParameters.cpp.

◆ getString() [1/2]

CepsString InputParameters::getString ( const keyType key) const

Reads a CepsString from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.

Interrupts the program if key is not provided.

Definition at line 199 of file InputParameters.cpp.

◆ getString() [2/2]

CepsString InputParameters::getString ( const keyType key,
const CepsString dval 
) const

Reads a CepsString from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.
[in]dvalDefault value used if key is not found in config.

Definition at line 207 of file InputParameters.cpp.

◆ hasKey()

CepsBool InputParameters::hasKey ( const keyType key) const

Tells if key exists in input file.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.

Definition at line 231 of file InputParameters.cpp.

◆ isActiveOption()

CepsBool InputParameters::isActiveOption ( const keyType key) const

Tells if key exists in configuration and is of "1","YES","ON" or "TRUE".

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.

Definition at line 237 of file InputParameters.cpp.

◆ isInactiveOption()

CepsBool InputParameters::isInactiveOption ( const keyType key) const

Tells if key exists in configuration and is of "0","NO","OFF" or "FALSE".

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.

Definition at line 245 of file InputParameters.cpp.

◆ operator()() [1/2]

CepsString InputParameters::operator() ( const keyType key) const

Reads a CepsString from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.

Interrupts the program if key is not provided.

Definition at line 219 of file InputParameters.cpp.

◆ operator()() [2/2]

CepsString InputParameters::operator() ( const keyType key,
const CepsString dval 
) const

Reads a CepsString from configuration.

Parameters
[in]keyNot case sensitive, trailing spaces trimmed.
[in]dvalDefault value used if key is not found in config.

Definition at line 225 of file InputParameters.cpp.

◆ operator=()

InputParameters& InputParameters::operator= ( const InputParameters that)
default

Assignment operator.

◆ read()

void InputParameters::read ( )

Reads all available parameters in specified file.

Definition at line 60 of file InputParameters.cpp.

◆ set() [1/3]

void InputParameters::set ( const keyType key,
const CepsInt value 
)

Adds or modifies an entry in the configuration.

Definition at line 284 of file InputParameters.cpp.

◆ set() [2/3]

void InputParameters::set ( const keyType key,
const CepsReal value 
)

Adds or modifies an entry in the configuration.

Definition at line 277 of file InputParameters.cpp.

◆ set() [3/3]

void InputParameters::set ( const keyType key,
const CepsString value 
)

Adds or modifies an entry in the configuration.

Definition at line 270 of file InputParameters.cpp.

◆ warnNoKey()

void InputParameters::warnNoKey ( const keyType key,
const CepsString defValue,
const CepsString type 
) const
protected

Prints an warning message if file misses a key and use the default value.

Parameters
[in]keyThe missing key. :(
[in]defValuethe value used instead of
[in]typeexpected type of value

Definition at line 262 of file InputParameters.cpp.

Field Documentation

◆ m_keyVals

CepsMap<keyType,CepsString> InputParameters::m_keyVals
private

The parameters stored as std::strings.

Definition at line 246 of file InputParameters.hpp.

◆ m_warnDefault

CepsBool InputParameters::m_warnDefault
private

Print missing values warnings if true.

Definition at line 247 of file InputParameters.hpp.


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