Go to the documentation of this file.
10 #include <type_traits>
15 #include <Eigen/Geometry>
29 std::string tname =
typeid(
T).name();
30 char* demangled_name = abi::__cxa_demangle(tname.c_str(), NULL, NULL, &
status);
33 tname = demangled_name;
34 std::free(demangled_name);
40 using var_t = std::variant<bool,
46 std::list<std::uint32_t>,
47 std::list<std::int32_t>,
49 types::ModularConvertedValueConfig,
107 bool getBool(
const std::string name);
115 float getFloat(
const std::string name);
123 std::uint32_t
getUint(
const std::string name);
131 std::int32_t
getInt(
const std::string name);
155 std::string
getString(
const std::string name);
163 std::list<bool>
getBoolList(
const std::string name);
179 std::list<std::uint32_t>
getUintList(
const std::string name);
187 std::list<std::int32_t>
getIntList(
const std::string name);
196 template <
typename Type,
int Rows,
int Columns>
202 auto mVal = get<Eigen::Matrix<Type, Eigen::Dynamic, Eigen::Dynamic>>(name);
204 if (Rows != mVal.rows())
206 std::stringstream ss;
207 ss <<
"The matrix has the wrong dimension: rows in config: " << mVal.rows()
208 <<
" , rows in getter " << Rows;
211 if (Columns != mVal.cols())
213 std::stringstream ss;
214 ss <<
"The matrix has the wrong dimension: columns in config: " << mVal.cols()
215 <<
" , columns in getter " << Columns;
236 virtual void print(std::stringstream&
s,
int indention)
const;
250 std::map<std::string, ConfigItemWithMetadata>
items;
270 auto it =
items.find(name);
271 if (it !=
items.end())
277 " is defined multiple times in " +
tagName(tag) +
280 else if (item.
tag > tag)
290 if constexpr (std::is_same_v<types::LinearConfig, T>)
292 auto oldItem = get_nothrow<T>(name);
293 if (oldItem.has_value())
309 template <
typename T>
313 auto it =
items.find(name);
314 if (it ==
items.end())
318 it->second.isRead =
true;
319 if (
const T* val = std::get_if<T>(&(it->second.data)))
326 template <
typename T>
328 get(
const std::string name)
330 auto it =
items.find(name);
331 if (it ==
items.end())
334 type_name<T>() +
" not found (name not found)");
336 it->second.isRead =
true;
337 if (
const T* val = std::get_if<T>(&(it->second.data)))
342 type_name<T>() +
" not found (types do not match)");
370 std::shared_ptr<Config> controllerConfig);
std::list< std::int32_t > getIntList(const std::string name)
Get a IntList (std::list<std::int32_t>) typed Config attribute by name.
void setFloatList(const std::string name, std::list< float > value, ConfigTag tag)
void setModularConvertedValueConfig(const std::string name, types::ModularConvertedValueConfig &&value, ConfigTag tag)
Config & getControllerConfig(const std::string controllerName)
std::list< float > getFloatList(const std::string name)
Get a FloatList (std::list<float>) typed Config attribute by name.
The ConfigElementNotFoundError class represents an error that is thrown when trying to get a config v...
The LinearConfig class represents a linear conversion and has a factor and offset.
void setBool(const std::string name, bool value, ConfigTag tag)
void setUintList(const std::string name, std::list< std::uint32_t > value, ConfigTag tag)
types::LinearConfig getLinearConfig(const std::string name)
Get a LinearConvertedValue typed Config attribute by name.
message(STATUS "Boost-Library-Dir: " "${Boost_LIBRARY_DIRS}") message(STATUS "Boost-LIBRARIES
void setInt(const std::string name, std::int32_t value, ConfigTag tag)
std::int32_t getInt(const std::string name)
Get a Int (std::int32_t) typed Config attribute by name.
std::shared_ptr< Value > value()
void setLinearConfig(const std::string name, types::LinearConfig &&value, ConfigTag tag)
ConfigTag
The ConfigTag is used when setting a config value.
std::optional< T > get_nothrow(const std::string name)
std::string createErrorMessageWithContext(std::string message, const Config &context)
Create an error message that prints part of the current Config object to make it easiier to find the ...
std::list< std::uint32_t > getUintList(const std::string name)
Get a UIntList (std::list<std::uint32_t>) typed Config attribute by name.
types::ModularConvertedValueConfig getModularConvertedValueConfig(const std::string &name)
Get a ModularConvertedValue typed Config attribute by name.
void setFloat(const std::string name, float value, ConfigTag tag)
bool getBool(const std::string name)
Get a Bool typed Config attribute by name.
The ConfigInsertError class represents an error that is thrown if an attempt is mode to set a config ...
std::variant< bool, float, std::uint32_t, std::int32_t, std::list< bool >, std::list< float >, std::list< std::uint32_t >, std::list< std::int32_t >, types::LinearConfig, types::ModularConvertedValueConfig, std::string, Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic >, Eigen::Matrix< std::uint32_t, Eigen::Dynamic, Eigen::Dynamic >, Eigen::Matrix< std::int32_t, Eigen::Dynamic, Eigen::Dynamic > > var_t
The variant type of the config map.
std::uint32_t getUint(const std::string name)
Get a Uint (std::uint32_t) typed Config attribute by name.
std::string tagName(ConfigTag tag)
virtual void onParsingFinished()
This method is called when the config is completely read form the HardwareConfig file.
void setBoolList(const std::string name, std::list< bool > value, ConfigTag tag)
void setString(const std::string name, std::string value, ConfigTag tag)
std::list< bool > getBoolList(const std::string name)
Get a BoolList (std::list<bool>) typed Config attribute by name.
std::map< std::string, ConfigItemWithMetadata > items
The Config class is the base class of all specialized configurations that have a direct key -> value ...
void setUint(const std::string name, std::uint32_t value, ConfigTag tag)
T get(const std::string name)
std::string getString(const std::string name)
Get a String typed Config attribute by name.
void setIntList(const std::string name, std::list< std::int32_t > value, ConfigTag tag)
std::map< std::string, std::shared_ptr< Config > > controllerConfigs
float getFloat(const std::string name)
Get a Float typed Config attribute by name.
Eigen::Matrix< Type, Rows, Columns > getMatrix(const std::string name)
Get a Matrix by name.
double s(double t, double s0, double v0, double a0, double j)
virtual ~Config()=default
Config with additional Config objects for controllers.
virtual bool checkAllItemsRead(std::vector< std::string > &errors) const
This method is called once the device has read the configuration data it needs.
virtual void print(std::stringstream &s, int indention) const
Print this configuration.
void addControllerConfig(const std::string controllerName, std::shared_ptr< Config > controllerConfig)
Add a Config for a controller with name.
void set(const std::string name, T value, ConfigTag tag)