From d62b85572ae9b8448df2e2347e54929533b47e78 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sat, 3 Feb 2018 12:21:57 +0100 Subject: [PATCH] remove property name from InitializerFunction's signature --- core/include/moveit/task_constructor/properties.h | 10 +++++----- core/src/properties.cpp | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/include/moveit/task_constructor/properties.h b/core/include/moveit/task_constructor/properties.h index 79f0640e..1599515b 100644 --- a/core/include/moveit/task_constructor/properties.h +++ b/core/include/moveit/task_constructor/properties.h @@ -50,7 +50,7 @@ namespace task_constructor { class Property; class PropertyMap; -/// initializer function, using another name from the passed property map +/// initializer function, using given name from the passed property map boost::any fromName(const PropertyMap& other, const std::string& other_name); enum PropertyInitializerSource { @@ -67,7 +67,7 @@ class Property { friend class PropertyMap; public: - typedef std::function InitializerFunction; + typedef std::function InitializerFunction; typedef std::map InitializerMap; Property(const std::type_index& type_index, const std::string& description, const boost::any& default_value); @@ -80,9 +80,9 @@ public: std::string typeName() const { return type_index_.name(); } /// configure initialization from source using an arbitrary function - Property &configureInitFrom(PropertyInitializerSource source, const InitializerFunction& f = fromName); - /// configure initialization from source using other property name - Property &configureInitFrom(PropertyInitializerSource source, const std::string& other_name); + Property &configureInitFrom(PropertyInitializerSource source, const InitializerFunction& f); + /// configure initialization from source using given other property name + Property &configureInitFrom(PropertyInitializerSource source, const std::string& name); private: std::string description_; diff --git a/core/src/properties.cpp b/core/src/properties.cpp index 318185a6..04996f86 100644 --- a/core/src/properties.cpp +++ b/core/src/properties.cpp @@ -39,6 +39,7 @@ #include #include #include +#include namespace moveit { namespace task_constructor { @@ -79,11 +80,9 @@ Property& Property::configureInitFrom(PropertyInitializerSource source, const Pr return *this; } -Property& Property::configureInitFrom(PropertyInitializerSource source, const std::string &other_name) +Property &Property::configureInitFrom(PropertyInitializerSource source, const std::string &name) { - initializers_[source] = [other_name](const PropertyMap& other, const std::string&) { - return fromName(other, other_name); - }; + initializers_[source] = [name](const PropertyMap& other) { return fromName(other, name); }; return *this; } @@ -109,7 +108,7 @@ void PropertyMap::configureInitFrom(PropertyInitializerSource source, const std: { for (auto &pair : props_) { if (properties.empty() || properties.count(pair.first)) - pair.second.configureInitFrom(source); + pair.second.configureInitFrom(source, std::bind(&fromName, std::placeholders::_1, pair.first)); } } @@ -161,7 +160,7 @@ void PropertyMap::performInitFrom(PropertyInitializerSource source, const Proper Property &p = pair.second; auto it = p.initializers_.find(source); if (it == p.initializers_.end()) continue; - const boost::any& value = it->second(other, pair.first); + const boost::any& value = it->second(other); if (value.empty()) continue; typeCheck(value, p.type_index_);