ORCA: Optimization-based framework for Robotic Control Applications
Public Types | Public Member Functions | List of all members
orca::common::Config Class Reference

Represents a set of parameters that can be loaded from a YAML file. More...

#include <Config.h>

+ Inheritance diagram for orca::common::Config:
+ Collaboration diagram for orca::common::Config:

Public Types

using Ptr = std::shared_ptr< Config >
 
using ParamMap = std::map< std::string, ParameterBase * >
 

Public Member Functions

 Config (const std::string &config_name)
 
virtual ~Config ()
 
void addParameter (const std::string &param_name, ParameterBase *param, ParamPolicy policy=ParamPolicy::Required, std::function< void()> on_loading_success=0)
 Returns true if all params added with have been set. More...
 
template<class T >
void addParameter (const std::string &param_name, T &param, ParamPolicy policy=ParamPolicy::Required, std::function< void()> on_loading_success=0)
 
ParameterBase * getParameter (const std::string &param_name)
 Returns a param via its name. More...
 
void print () const
 Print all parameters to std::cout. More...
 
bool loadFromFile (const std::string &yaml_url)
 Configure the task from YAML/JSON file. It must contain all the required parameters. More...
 
bool loadFromString (const std::string &yaml_str)
 Configure the task from YAML/JSON string. It must contain all the required parameters. More...
 
bool areAllRequiredParametersSet () const
 
const ParamMapgetAllParameters () const
 
void onSuccess (std::function< void()> f)
 
- Public Member Functions inherited from orca::common::OrcaObject
 OrcaObject (const std::string &name)
 
virtual ~OrcaObject ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 

Detailed Description

Represents a set of parameters that can be loaded from a YAML file.

Member Typedef Documentation

using orca::common::Config::ParamMap = std::map<std::string, ParameterBase* >
using orca::common::Config::Ptr = std::shared_ptr<Config>

Constructor & Destructor Documentation

Config::Config ( const std::string &  config_name)
Config::~Config ( )
virtual

Member Function Documentation

void Config::addParameter ( const std::string &  param_name,
ParameterBase *  param,
ParamPolicy  policy = ParamPolicy::Required,
std::function< void()>  on_loading_success = 0 
)

Returns true if all params added with have been set.

Returns
true is all the required parameters are loaded properly
template<class T >
void orca::common::Config::addParameter ( const std::string &  param_name,
T &  param,
ParamPolicy  policy = ParamPolicy::Required,
std::function< void()>  on_loading_success = 0 
)
inline
bool Config::areAllRequiredParametersSet ( ) const
const Config::ParamMap & Config::getAllParameters ( ) const
ParameterBase * Config::getParameter ( const std::string &  param_name)

Returns a param via its name.

Parameters
param_nameThe name of the param (might not exist)
Returns
orca::common::ParameterBase* The param pointer, nullptr if if does not exists
bool Config::loadFromFile ( const std::string &  yaml_url)

Configure the task from YAML/JSON file. It must contain all the required parameters.

Returns
true is all the required parameters are loaded properly
bool Config::loadFromString ( const std::string &  yaml_str)

Configure the task from YAML/JSON string. It must contain all the required parameters.

Returns
true is all the required parameters are loaded properly
void Config::onSuccess ( std::function< void()>  f)
void Config::print ( ) const

Print all parameters to std::cout.


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