38 emitter_ =
new YAML::Emitter;
39 emitter_->SetDoublePrecision(std::numeric_limits<double>::digits10);
40 if (config_ofs_.tellp() != 0)
42 *emitter_ << YAML::Newline;
44 *emitter_ << YAML::BeginMap;
53 *emitter_ << YAML::EndMap;
54 config_ofs_ << emitter_->c_str();
65 explicit Writer(
const std::string& file_name) :
66 config_ofs_(file_name.c_str())
87 void descend(
const std::string &map_name,
const std::size_t num_entries)
89 *emitter_ << YAML::Key << map_name;
90 *emitter_ << YAML::Value;
91 *emitter_ << YAML::BeginMap;
108 *emitter_ << YAML::EndMap;
120 template <
typename t_Scalar,
123 void writeCompound(
const Eigen::Matrix<t_Scalar, t_rows, 1, t_flags> &entry,
124 const std::string & entry_name)
127 *emitter_ << YAML::Key << entry_name;
128 *emitter_ << YAML::Value << YAML::Flow;
129 *emitter_ << YAML::BeginSeq;
133 *emitter_ << entry(i);
136 *emitter_ << YAML::EndSeq;
152 template <
typename t_Scalar,
156 void writeCompound(
const Eigen::Matrix<t_Scalar, t_rows, t_cols, t_flags> &entry,
157 const std::string& entry_name)
159 descend(entry_name, 3);
161 writeScalar(entry.cols(),
"cols");
162 writeScalar(entry.rows(),
"rows");
165 *emitter_ << YAML::Key <<
"data";
166 *emitter_ << YAML::Value << YAML::Flow;
167 *emitter_ << YAML::BeginSeq;
173 *emitter_ << entry(j, i);
177 *emitter_ << YAML::EndSeq;
191 template<
typename t_VectorEntryType>
192 void writeCompound(
const std::vector< std::vector<t_VectorEntryType> > & entry,
193 const std::string & entry_name)
const 195 *emitter_ << YAML::Key << entry_name;
196 *emitter_ << YAML::Value << YAML::Flow;
197 *emitter_ << YAML::BeginSeq;
199 for(std::size_t i = 0; i < entry.size(); ++i)
201 for(std::size_t j = 0; j < entry[i].size(); ++j)
203 *emitter_ << entry[i][j];
207 *emitter_ << YAML::EndSeq;
219 template <
typename t_VectorEntryType>
221 const std::string & entry_name)
223 *emitter_ << YAML::Key << entry_name;
224 *emitter_ << YAML::Value << YAML::Flow;
225 *emitter_ << YAML::BeginSeq;
227 for(std::size_t i = 0; i < entry.size(); ++i)
229 *emitter_ << entry[i];
232 *emitter_ << YAML::EndSeq;
244 template <
typename t_EnumType>
246 const std::string & entry_name)
248 *emitter_ << YAML::Key << entry_name << YAML::Value << entry;
260 template <
typename t_EntryType>
262 const std::string & entry_name)
264 *emitter_ << YAML::Key << entry_name << YAML::Value << entry;
YAML::Emitter * emitter_
instance of YAML emitter, is destroyed and reinitialized by flush()
void descend(const std::string &map_name, const std::size_t num_entries)
Starts a nested map in the configuration file.
void ascend()
Ends a nested map in the configuration file.
void destroyEmitter()
Destroy emitter.
Writer(const std::string &file_name)
Constructor.
EIGEN_DEFAULT_DENSE_INDEX_TYPE EigenIndex
void writeCompound(const Eigen::Matrix< t_Scalar, t_rows, t_cols, t_flags > &entry, const std::string &entry_name)
Write a configuration entry (matrix)
void flush()
Flush the configuration to the file.
Configuration writer class.
void writeCompound(const std::vector< t_VectorEntryType > &entry, const std::string &entry_name)
Read configuration entry (std::vector)
void writeCompound(const Eigen::Matrix< t_Scalar, t_rows, 1, t_flags > &entry, const std::string &entry_name)
Write a configuration entry (vector)
The root namespace of HuMoTo.
void initEmitter()
Initialize emitter.
void writeEnum(const t_EnumType entry, const std::string &entry_name)
Write a configuration entry (enum)
void writeCompound(const std::vector< std::vector< t_VectorEntryType > > &entry, const std::string &entry_name) const
Write configuration entry (std::vector<std::vector<std::string>>)
void initRoot()
Starts a nested map in the configuration file.
std::ofstream config_ofs_
output file stream
void writeScalar(const t_EntryType entry, const std::string &entry_name)
Write a configuration entry (scalar template)