12#ifndef __CONFIGURATIONS_H
13#define __CONFIGURATIONS_H
17#include <unordered_map>
26 template <
class T>
struct ConfigurationProperty
29 std::string Description =
"";
35 std::string Description =
"";
39 static unsigned int numberProperties;
40 static std::unordered_map<std::string, ConfigurationPropertySupportedTypes::SupportedTypes> propertyTypes;
41 static std::unordered_map<std::string, void *> properties;
49 return propertyTypes[id];
59 static ExportProperty GetPropertyForExport(
const std::string &
id,
70 return numberProperties;
93 static void RemoveProperty(
const std::string &
id);
98 return !(propertyTypes.find(
id) == propertyTypes.end());
103 return GetPropertyType(
id) == ConfigurationPropertySupportedTypes::GetSupportedType<T>();
108 const std::string &
type,
109 const std::string &value,
116 if (!ConfigurationPropertySupportedTypes::IsSupported<T>())
117 throw std::invalid_argument(
"Property '" +
id +
"': type not supported");
122 propertyTypes.insert(std::pair<std::string, ConfigurationPropertySupportedTypes::SupportedTypes>(
124 ConfigurationPropertySupportedTypes::GetSupportedType<T>()));
130 property.Value = value;
135 static void AddProperty(
const std::string &
id,
const char *value =
"",
const std::string &
description =
"");
141 throw std::invalid_argument(
"");
146 std::string
valueType = ConfigurationPropertySupportedTypes::TypeToString<T>();
147 throw std::invalid_argument(
"Property '" +
id +
"' has type " +
propertyType +
" and not " +
valueType);
151 property.Value = value;
161 throw std::invalid_argument(
"");
166 std::string
valueType = ConfigurationPropertySupportedTypes::TypeToString<T>();
167 throw std::invalid_argument(
"Property '" +
id +
"' has type " +
propertyType +
" and not " +
valueType);
171 return property.Value;
SupportedTypes
Definition ConfigurationPropertySupportedTypes.hpp:27
static std::string TypeToString()
Definition ConfigurationPropertySupportedTypes.hpp:83
Definition Configurations.hpp:24
static void Reset()
Reset the Configurations class.
Definition Configurations.cpp:499
static const unsigned int & NumberProperties()
Definition Configurations.hpp:68
~Configurations()
Definition Configurations.hpp:63
static void SetPropertyValue(const std::string &id, const T value)
Set Property Value.
Definition Configurations.hpp:138
static bool ExistsProperty(const std::string &id)
Check if Property exists.
Definition Configurations.hpp:96
static void ConvertPropertyFromString(const std::string &id, const std::string &type, const std::string &value, const std::string &description="")
Convert Property by string Type and string value.
Definition Configurations.cpp:149
static const T & GetPropertyValue(const std::string &id)
Get Property Value.
Definition Configurations.hpp:158
static void Initialize(const int &argc, char **argv, const std::string &format="id:type=value")
Definition Configurations.cpp:384
static void ExportToIni(const std::string &filePath, const bool &append=false, const std::string §ion="")
Export the configuration to ini file.
Definition Configurations.cpp:458
static void ExportToCsv(const std::string &filePath, const bool &append=false, const char &separator=';')
Export the configuration to csv file.
Definition Configurations.cpp:417
static void InitializeFromCsv(const std::string &ConfigurationsFile, const bool &hasHeader=true, const char &separator=';')
Read the configuration from csv file.
Definition Configurations.cpp:264
static void AddProperty(const std::string &id, const T &value=T(), const std::string &description="")
Add or Overwrite Property.
Definition Configurations.hpp:114
static void InitializeFromIni(const std::string &ConfigurationsFile)
Read the configuration from ini file.
Definition Configurations.cpp:328
static bool CheckPropertyType(const std::string &id)
Definition Configurations.hpp:101
Eigen column vector.
Definition Eigen_Array.hpp:23
Definition Eigen_Array.cpp:22