FDCL Param Class
param.hpp
1 #ifndef FDCL_PARAM_H
2 #define FDCL_PARAM_H
3 
4 #include <iostream>
5 #include <fstream>
6 #include <string>
7 #include <sstream>
8 #include <iomanip> // std::setprecision
9 
10 #include "Eigen/Dense"
11 
12 namespace fdcl
13 {
14 
34 class param
35 {
36 
37 public:
38  std::string file_name;
41  std::fstream file_stream;
43  param();
44  param(std::string file_name);
45  ~param();
46 
51  void open(std::string fname);
52 
53 
57  void close();
58 
59 
65  void read(const std::string param_name, bool &value);
66 
67 
73  void read(const std::string param_name, double &value);
74 
75 
81  void read(const std::string param_name, int &value);
82 
83 
89  void read(const std::string param_name, std::string &value);
90 
91 
97  void read(const std::string param_name,
98  Eigen::Matrix<double, 3, 3> &value);
99 
100 
106  void read(const std::string param_name,
107  Eigen::Matrix<double, 4, 1> &value);
108 
109 
115  void read(const std::string param_name,
116  Eigen::Matrix<double, 3, 1> &value);
117 
118 
126  template<typename Derived>
127  void read(const std::string param_name, Eigen::MatrixBase<Derived> &value);
128 
129 
135  void save(const std::string param_name, bool value);
136 
137 
143  void save(const std::string param_name, double value);
144 
145 
151  void save(const std::string param_name, int value);
152 
153 
159  void save(const std::string param_name, const std::string value);
160 
161 
167  void save(const std::string param_name,
168  Eigen::Matrix<double, 3, 3> &value);
169 
170 
178  template<typename Derived>
179  void save(const std::string param_name, Eigen::MatrixBase<Derived> &value);
180 
181 
182 private:
188  std::string find_line(const std::string param_name);
189 
190 
196  void replace_value(const std::string param_name, std::string new_value);
197 
198 }; // end of fdcl::param class
199 } // end of fdcl namespace
200 
201 #endif
void read(const std::string param_name, bool &value)
Saving and loading parameters.
Definition: param.hpp:34
std::string file_name
Definition: param.hpp:38
std::fstream file_stream
Definition: param.hpp:41
Definition: param.hpp:12
void close()
void open(std::string fname)
void save(const std::string param_name, bool value)