humoto
Public Member Functions | Private Member Functions | Private Attributes | List of all members
humoto::config::yaml::Reader Class Reference

Detailed Description

Configuration reader class.

Definition at line 22 of file reader.h.

#include <reader.h>

Public Member Functions

 Reader (const std::string &file_name)
 Constructor. More...
 
 Reader ()
 Default constructor. More...
 
void ascend ()
 Ascend from the current entry to its parent. More...
 
bool descend (const std::string &child_name)
 Descend to the entry with the given name. More...
 
template<typename t_Scalar , int t_rows, int t_flags>
void readCompound (Eigen::Matrix< t_Scalar, t_rows, 1, t_flags > &entry, const std::string &entry_name, const bool crash_on_missing_entry=false)
 Read configuration entry (vector) More...
 
template<typename t_Scalar , int t_rows, int t_cols, int t_flags>
void readCompound (Eigen::Matrix< t_Scalar, t_rows, t_cols, t_flags > &entry, const std::string &entry_name, const bool crash_on_missing_entry=false)
 Read a configuration entry (matrix) More...
 
template<typename t_VectorEntryType >
void readCompound (std::vector< t_VectorEntryType > &entry, const std::string &entry_name, const bool crash_on_missing_entry=false)
 Read configuration entry (std::vector) More...
 
template<typename t_EnumerationType >
void readEnum (t_EnumerationType &entry, const std::string &entry_name, const bool crash_on_missing_entry=false)
 Read configuration entry (an enum). This method is added since an explicit casting to integer is needed. More...
 
template<typename t_EntryType >
void readScalar (t_EntryType &entry, const std::string &entry_name, const bool crash_on_missing_entry=false)
 Read configuration entry (scalar template) More...
 

Private Member Functions

const YAML::Node * getCurrentNode ()
 Get current node. More...
 
void openFile (const std::string &file_name)
 open configuration file More...
 

Private Attributes

std::ifstream config_ifs_
 input file stream More...
 
std::stack< const YAML::Node * > node_stack_
 Stack of nodes. More...
 
YAML::Parser parser_
 instance of YAML parser More...
 
YAML::Node root_node_
 root node More...
 

Constructor & Destructor Documentation

◆ Reader() [1/2]

humoto::config::yaml::Reader::Reader ( const std::string &  file_name)
inlineexplicit

Constructor.

Parameters
[in]file_name

Definition at line 80 of file reader.h.

◆ Reader() [2/2]

humoto::config::yaml::Reader::Reader ( )
inline

Default constructor.

Definition at line 89 of file reader.h.

Member Function Documentation

◆ ascend()

void humoto::config::yaml::Reader::ascend ( )
inline

Ascend from the current entry to its parent.

Definition at line 121 of file reader.h.

◆ descend()

bool humoto::config::yaml::Reader::descend ( const std::string &  child_name)
inline

Descend to the entry with the given name.

Parameters
[in]child_namechild node name
Returns
true if successful.

Definition at line 102 of file reader.h.

◆ getCurrentNode()

const YAML::Node* humoto::config::yaml::Reader::getCurrentNode ( )
inlineprivate

Get current node.

Returns
pointer to the current node

Definition at line 68 of file reader.h.

◆ openFile()

void humoto::config::yaml::Reader::openFile ( const std::string &  file_name)
inlineprivate

open configuration file

Parameters
[in]file_name

Definition at line 44 of file reader.h.

◆ readCompound() [1/3]

template<typename t_Scalar , int t_rows, int t_flags>
void humoto::config::yaml::Reader::readCompound ( Eigen::Matrix< t_Scalar, t_rows, 1, t_flags > &  entry,
const std::string &  entry_name,
const bool  crash_on_missing_entry = false 
)
inline

Read configuration entry (vector)

Template Parameters
t_ScalarEigen template parameter
t_rowsEigen template parameter
t_flagsEigen template parameter
Parameters
[out]entryconfiguration parameter
[in]entry_namename of the configuration parameter
[in]crash_on_missing_entry

Definition at line 141 of file reader.h.

◆ readCompound() [2/3]

template<typename t_Scalar , int t_rows, int t_cols, int t_flags>
void humoto::config::yaml::Reader::readCompound ( Eigen::Matrix< t_Scalar, t_rows, t_cols, t_flags > &  entry,
const std::string &  entry_name,
const bool  crash_on_missing_entry = false 
)
inline

Read a configuration entry (matrix)

Template Parameters
t_ScalarEigen template parameter
t_rowsEigen template parameter
t_colsEigen template parameter
t_flagsEigen template parameter
Parameters
[out]entrydata
[in]entry_namename
[in]crash_on_missing_entry

Definition at line 194 of file reader.h.

◆ readCompound() [3/3]

template<typename t_VectorEntryType >
void humoto::config::yaml::Reader::readCompound ( std::vector< t_VectorEntryType > &  entry,
const std::string &  entry_name,
const bool  crash_on_missing_entry = false 
)
inline

Read configuration entry (std::vector)

Template Parameters
t_VectorEntryTypetype of the entry of std::vector
Parameters
[out]entryconfiguration parameter
[in]entry_namename of the configuration parameter
[in]crash_on_missing_entry

Definition at line 243 of file reader.h.

◆ readEnum()

template<typename t_EnumerationType >
void humoto::config::yaml::Reader::readEnum ( t_EnumerationType &  entry,
const std::string &  entry_name,
const bool  crash_on_missing_entry = false 
)
inline

Read configuration entry (an enum). This method is added since an explicit casting to integer is needed.

Template Parameters
t_EnumerationTypeenumeration type
Parameters
[out]entryconfiguration parameter
[in]entry_namename of the configuration parameter
[in]crash_on_missing_entry

Definition at line 312 of file reader.h.

◆ readScalar()

template<typename t_EntryType >
void humoto::config::yaml::Reader::readScalar ( t_EntryType &  entry,
const std::string &  entry_name,
const bool  crash_on_missing_entry = false 
)
inline

Read configuration entry (scalar template)

Template Parameters
t_EntryTypetype of the entry
Parameters
[out]entryconfiguration parameter
[in]entry_namename of the configuration parameter
[in]crash_on_missing_entry

Definition at line 282 of file reader.h.

Member Data Documentation

◆ config_ifs_

std::ifstream humoto::config::yaml::Reader::config_ifs_
private

input file stream

Definition at line 26 of file reader.h.

◆ node_stack_

std::stack<const YAML::Node *> humoto::config::yaml::Reader::node_stack_
private

Stack of nodes.

Definition at line 35 of file reader.h.

◆ parser_

YAML::Parser humoto::config::yaml::Reader::parser_
private

instance of YAML parser

Definition at line 29 of file reader.h.

◆ root_node_

YAML::Node humoto::config::yaml::Reader::root_node_
private

root node

Definition at line 32 of file reader.h.


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