CEPS  24.01
Cardiac ElectroPhysiology Simulator
InputParameters.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
32 #pragma once
33 
34 #include <cerrno>
35 #include <iterator>
36 #include <utility>
37 
40 
71 {
72 
74 
75  public:
76 
80 
86  explicit InputParameters(const CepsString& inputFile, CepsBool warnDefault = false);
87 
89  InputParameters(const InputParameters& that) = default;
90 
93  operator=(const InputParameters& that) = default;
94 
96  ~InputParameters() override;
97 
99  void
100  read();
101 
102  // Get values from input file, no default value
103 
109  CepsReal
110  getReal(const keyType& key) const;
111 
118  getMathVertex(const keyType& key) const;
119 
125  CepsInt
126  getInt(const keyType& key) const;
127 
133  CepsString
134  getString(const keyType& key) const;
135 
141  CepsString
142  operator()(const keyType& key) const;
143 
144  // Same with default values
145 
150  CepsReal
151  getReal(const keyType& key, const CepsReal& dval) const;
152 
158  getMathVertex(const keyType& key, const CepsMathVertex& dval) const;
159 
164  CepsInt
165  getInt(const keyType& key, const CepsInt& dval) const;
166 
171  CepsString
172  getString(const keyType& key, const CepsString& dval) const;
173 
178  CepsString
179  operator()(const keyType& key, const CepsString& dval) const;
180 
181  // Change config
182 
185  void
186  set(const keyType& key, const CepsString& value);
187 
190  void
191  set(const keyType& key, const CepsReal& value);
192 
195  void
196  set(const keyType& key, const CepsInt& value);
197 
200  void
201  erase(const keyType& key);
202 
203  // Quick information
204 
208  CepsBool
209  hasKey(const keyType& key) const;
210 
214  CepsBool
215  isActiveOption(const keyType& key) const;
216 
220  CepsBool
221  isInactiveOption(const keyType& key) const;
222 
223 
224  protected:
225 
231  void
232  errIfNoKey(const keyType& key, const CepsString& type) const;
233 
240  void
241  warnNoKey(const keyType& key, const CepsString& defValue, const CepsString& type) const;
242 
243 
244  private:
245 
248 
249 };
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
std::map< _Key, _Tp, _Compare, _Alloc > CepsMap
C++ map.
Definition: CepsTypes.hpp:196
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
Eigen::Matrix< CepsScalar, 3, 1 > CepsMathVertex
Vertex, eigen format.
Definition: CepsTypes.hpp:135
int32_t CepsInt
Need 32 bit integer.
Definition: CepsTypes.hpp:106
Base class that regroups common reader functionalities.
Definition: FileReader.hpp:43
Reads and stores simulation configuration.
void set(const keyType &key, const CepsString &value)
Adds or modifies an entry in the configuration.
InputParameters()
Empty constructor.
CepsBool isInactiveOption(const keyType &key) const
Tells if key exists in configuration and is of "0","NO","OFF" or "FALSE".
void read()
Reads all available parameters in specified file.
CepsString operator()(const keyType &key) const
Reads a CepsString from configuration.
CepsMap< keyType, CepsString > m_keyVals
The parameters stored as std::strings.
InputParameters & operator=(const InputParameters &that)=default
Assignment operator.
CepsMathVertex getMathVertex(const keyType &key) const
Reads 3 floating point values from configuration.
void errIfNoKey(const keyType &key, const CepsString &type) const
Prints an error message if file misses a key.
void erase(const keyType &key)
Removes an entry in the configuration.
CepsInt getInt(const keyType &key) const
Reads an integer value from configuration.
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.
InputParameters(const InputParameters &that)=default
Copy constructor.
CepsBool m_warnDefault
Print missing values warnings if true.
CepsBool hasKey(const keyType &key) const
Tells if key exists in input file.
~InputParameters() override
Destructor.
CepsBool isActiveOption(const keyType &key) const
Tells if key exists in configuration and is of "1","YES","ON" or "TRUE".
CepsString getString(const keyType &key) const
Reads a CepsString from configuration.
CepsReal getReal(const keyType &key) const
Reads a floating point value from configuration.