Skip to content
Snippets Groups Projects
Commit 3fc2bc11 authored by Christoph Pohl's avatar Christoph Pohl
Browse files

Add replacement of cmake and env variables to string variants

parent e977b1aa
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,6 @@ namespace armarx::aron::component_config ...@@ -44,7 +44,6 @@ namespace armarx::aron::component_config
auto value = data::Int::DynamicCastAndCheck(i); auto value = data::Int::DynamicCastAndCheck(i);
auto name = pathToName(i); auto name = pathToName(i);
property_user_->getProperty(value->getValue(), name); property_user_->getProperty(value->getValue(), name);
i = value;
} }
void void
...@@ -54,7 +53,6 @@ namespace armarx::aron::component_config ...@@ -54,7 +53,6 @@ namespace armarx::aron::component_config
auto value = data::Float::DynamicCastAndCheck(f); auto value = data::Float::DynamicCastAndCheck(f);
auto name = pathToName(f); auto name = pathToName(f);
property_user_->getProperty(value->getValue(), name); property_user_->getProperty(value->getValue(), name);
f = value;
} }
void void
...@@ -64,7 +62,6 @@ namespace armarx::aron::component_config ...@@ -64,7 +62,6 @@ namespace armarx::aron::component_config
auto value = data::Double::DynamicCastAndCheck(d); auto value = data::Double::DynamicCastAndCheck(d);
auto name = pathToName(d); auto name = pathToName(d);
property_user_->getProperty(value->getValue(), name); property_user_->getProperty(value->getValue(), name);
d = value;
} }
void void
...@@ -74,7 +71,6 @@ namespace armarx::aron::component_config ...@@ -74,7 +71,6 @@ namespace armarx::aron::component_config
auto value = data::Bool::DynamicCastAndCheck(b); auto value = data::Bool::DynamicCastAndCheck(b);
auto name = pathToName(b); auto name = pathToName(b);
property_user_->getProperty(value->getValue(), name); property_user_->getProperty(value->getValue(), name);
b = value;
} }
void void
...@@ -83,8 +79,13 @@ namespace armarx::aron::component_config ...@@ -83,8 +79,13 @@ namespace armarx::aron::component_config
INPUT_GUARD(string); INPUT_GUARD(string);
auto value = data::String::DynamicCastAndCheck(string); auto value = data::String::DynamicCastAndCheck(string);
auto name = pathToName(string); auto name = pathToName(string);
property_user_->getProperty(value->getValue(), name); auto property = property_user_->getProperty<std::string>(name);
string = value; if (not property.getValue().empty()){
value->getValue() = property.getValueAndReplaceAllVars();
} else
{
value->getValue() = "";
}
} }
void void
...@@ -130,7 +131,6 @@ namespace armarx::aron::component_config ...@@ -130,7 +131,6 @@ namespace armarx::aron::component_config
auto data = data::Int::DynamicCastAndCheck(enumData); auto data = data::Int::DynamicCastAndCheck(enumData);
auto name = pathToName(enumData); auto name = pathToName(enumData);
property_user_->getProperty(data->getValue(), name); property_user_->getProperty(data->getValue(), name);
enumData = data;
} }
void void
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <RobotAPI/libraries/aron/core/data/variant/All.h> #include <RobotAPI/libraries/aron/core/data/variant/All.h>
#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h>
#include <ArmarXCore/core/application/properties/Property.h>
#include "PropertyHelper.h" #include "PropertyHelper.h"
namespace armarx::aron::component_config::products namespace armarx::aron::component_config::products
...@@ -30,6 +31,7 @@ namespace armarx::aron::component_config::products ...@@ -30,6 +31,7 @@ namespace armarx::aron::component_config::products
std::string std::string
PropertyHelper<type::Descriptor::INT>::to_string(const data::VariantPtr& ptr) const PropertyHelper<type::Descriptor::INT>::to_string(const data::VariantPtr& ptr) const
{ {
ARMARX_TRACE;
return simox::alg::to_string(data::Int::DynamicCast(ptr)->getValue()); return simox::alg::to_string(data::Int::DynamicCast(ptr)->getValue());
} }
...@@ -37,6 +39,7 @@ namespace armarx::aron::component_config::products ...@@ -37,6 +39,7 @@ namespace armarx::aron::component_config::products
std::string std::string
PropertyHelper<type::Descriptor::BOOL>::to_string(const data::VariantPtr& ptr) const PropertyHelper<type::Descriptor::BOOL>::to_string(const data::VariantPtr& ptr) const
{ {
ARMARX_TRACE;
return simox::alg::to_string(data::Bool::DynamicCast(ptr)->getValue()); return simox::alg::to_string(data::Bool::DynamicCast(ptr)->getValue());
} }
...@@ -44,6 +47,7 @@ namespace armarx::aron::component_config::products ...@@ -44,6 +47,7 @@ namespace armarx::aron::component_config::products
std::string std::string
PropertyHelper<type::Descriptor::STRING>::to_string(const data::VariantPtr& ptr) const PropertyHelper<type::Descriptor::STRING>::to_string(const data::VariantPtr& ptr) const
{ {
ARMARX_TRACE;
return data::String::DynamicCast(ptr)->getValue(); return data::String::DynamicCast(ptr)->getValue();
} }
...@@ -51,6 +55,7 @@ namespace armarx::aron::component_config::products ...@@ -51,6 +55,7 @@ namespace armarx::aron::component_config::products
std::string std::string
PropertyHelper<type::Descriptor::FLOAT>::to_string(const data::VariantPtr& ptr) const PropertyHelper<type::Descriptor::FLOAT>::to_string(const data::VariantPtr& ptr) const
{ {
ARMARX_TRACE;
return simox::alg::to_string(data::Float::DynamicCast(ptr)->getValue()); return simox::alg::to_string(data::Float::DynamicCast(ptr)->getValue());
} }
...@@ -58,6 +63,7 @@ namespace armarx::aron::component_config::products ...@@ -58,6 +63,7 @@ namespace armarx::aron::component_config::products
std::string std::string
PropertyHelper<type::Descriptor::INT_ENUM>::to_string(const data::VariantPtr& ptr) const PropertyHelper<type::Descriptor::INT_ENUM>::to_string(const data::VariantPtr& ptr) const
{ {
ARMARX_TRACE;
// TODO: this is should use the name of the enum value // TODO: this is should use the name of the enum value
return simox::alg::to_string(data::Int::DynamicCast(ptr)->getValue()); return simox::alg::to_string(data::Int::DynamicCast(ptr)->getValue());
} }
...@@ -66,6 +72,7 @@ namespace armarx::aron::component_config::products ...@@ -66,6 +72,7 @@ namespace armarx::aron::component_config::products
std::string std::string
PropertyHelper<type::Descriptor::DOUBLE>::to_string(const data::VariantPtr& ptr) const PropertyHelper<type::Descriptor::DOUBLE>::to_string(const data::VariantPtr& ptr) const
{ {
ARMARX_TRACE;
return simox::alg::to_string(data::Double::DynamicCast(ptr)->getValue()); return simox::alg::to_string(data::Double::DynamicCast(ptr)->getValue());
} }
...@@ -74,35 +81,38 @@ namespace armarx::aron::component_config::products ...@@ -74,35 +81,38 @@ namespace armarx::aron::component_config::products
products::PropertyHelper<type::Descriptor::INT>::from_string(const std::string& string, products::PropertyHelper<type::Descriptor::INT>::from_string(const std::string& string,
const armarx::aron::Path& path) const const armarx::aron::Path& path) const
{ {
ARMARX_TRACE;
return make_int(std::stoi(string), path); return make_int(std::stoi(string), path);
} }
template <> template <>
aron::data::VariantPtr aron::data::VariantPtr
products::PropertyHelper<type::Descriptor::FLOAT>::from_string(const std::string& string, products::PropertyHelper<type::Descriptor::FLOAT>::from_string(const std::string& string,
const armarx::aron::Path& path) const const armarx::aron::Path& path) const
{ {
ARMARX_TRACE;
return make_float(std::stof(string), path); return make_float(std::stof(string), path);
} }
template <> template <>
aron::data::VariantPtr aron::data::VariantPtr
products::PropertyHelper<type::Descriptor::DOUBLE>::from_string(const std::string& string, products::PropertyHelper<type::Descriptor::DOUBLE>::from_string(const std::string& string,
const armarx::aron::Path& path) const const armarx::aron::Path& path) const
{ {
ARMARX_TRACE;
return make_double(std::stod(string), path); return make_double(std::stod(string), path);
} }
template <> template <>
aron::data::VariantPtr aron::data::VariantPtr
products::PropertyHelper<type::Descriptor::BOOL>::from_string(const std::string& string, products::PropertyHelper<type::Descriptor::BOOL>::from_string(const std::string& string,
const armarx::aron::Path& path) const const armarx::aron::Path& path) const
{ {
ARMARX_TRACE;
if (string == "true") if (string == "true")
{ {
return make_bool(true, path); return make_bool(true, path);
} } else if (string == "false")
else if (string == "false")
{ {
return make_bool(false, path); return make_bool(false, path);
} }
...@@ -112,60 +122,78 @@ namespace armarx::aron::component_config::products ...@@ -112,60 +122,78 @@ namespace armarx::aron::component_config::products
template <> template <>
aron::data::VariantPtr aron::data::VariantPtr
products::PropertyHelper<type::Descriptor::INT_ENUM>::from_string(const std::string& string, products::PropertyHelper<type::Descriptor::INT_ENUM>::from_string(const std::string& string,
const armarx::aron::Path& path) const const armarx::aron::Path& path) const
{ {
// TODO: this might not work // TODO: this might not work
ARMARX_TRACE;
return make_int(std::stoi(string), path); return make_int(std::stoi(string), path);
} }
template <> template <>
aron::data::VariantPtr aron::data::VariantPtr
products::PropertyHelper<type::Descriptor::STRING>::from_string(const std::string& string, products::PropertyHelper<type::Descriptor::STRING>::from_string(const std::string& string,
const armarx::aron::Path& path) const const armarx::aron::Path& path) const
{ {
return make_string(string, path); ARMARX_TRACE;
std::string formatted_string = "";
if (not string.empty())
{
formatted_string = armarx::FileSystemPathBuilder_ApplyFormattingAndResolveEnvAndCMakeVars(string);
}
return make_string(formatted_string, path);
} }
template <> template <>
void void
products::PropertyHelper<type::Descriptor::INT>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, products::PropertyHelper<type::Descriptor::INT>::set_value_from_string(const armarx::aron::data::VariantPtr& variant,
const std::string& string) const const std::string& string) const
{ {
ARMARX_TRACE;
data::Int::DynamicCast(variant)->getValue() = std::stoi(string); data::Int::DynamicCast(variant)->getValue() = std::stoi(string);
} }
template <> template <>
void void
products::PropertyHelper<type::Descriptor::FLOAT>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, products::PropertyHelper<type::Descriptor::FLOAT>::set_value_from_string(const armarx::aron::data::VariantPtr& variant,
const std::string& string) const const std::string& string) const
{ {
ARMARX_TRACE;
data::Float::DynamicCast(variant)->getValue() = std::stof(string); data::Float::DynamicCast(variant)->getValue() = std::stof(string);
} }
template <> template <>
void void
products::PropertyHelper<type::Descriptor::DOUBLE>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, products::PropertyHelper<type::Descriptor::DOUBLE>::set_value_from_string(const armarx::aron::data::VariantPtr& variant,
const std::string& string) const const std::string& string) const
{ {
ARMARX_TRACE;
data::Double::DynamicCast(variant)->getValue() = std::stod(string); data::Double::DynamicCast(variant)->getValue() = std::stod(string);
} }
template <> template <>
void void
products::PropertyHelper<type::Descriptor::BOOL>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, products::PropertyHelper<type::Descriptor::BOOL>::set_value_from_string(const armarx::aron::data::VariantPtr& variant,
const std::string& string) const const std::string& string) const
{ {
ARMARX_TRACE;
data::Bool::DynamicCast(variant)->getValue() = string == "true"; data::Bool::DynamicCast(variant)->getValue() = string == "true";
} }
template <> template <>
void void
products::PropertyHelper<type::Descriptor::STRING>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, products::PropertyHelper<type::Descriptor::STRING>::set_value_from_string(const armarx::aron::data::VariantPtr& variant,
const std::string& string) const const std::string& string) const
{ {
ARMARX_TRACE;
data::String::DynamicCast(variant)->getValue() = string; data::String::DynamicCast(variant)->getValue() = string;
} }
template <> template <>
void void
products::PropertyHelper<type::Descriptor::INT_ENUM>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, products::PropertyHelper<type::Descriptor::INT_ENUM>::set_value_from_string(const armarx::aron::data::VariantPtr& variant,
const std::string& string) const const std::string& string) const
{ {
ARMARX_TRACE;
data::Int::DynamicCast(variant)->getValue() = std::stoi(string); data::Int::DynamicCast(variant)->getValue() = std::stoi(string);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment