mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
remove property name from InitializerFunction's signature
This commit is contained in:
parent
0d6dbee215
commit
d62b85572a
@ -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<boost::any(const PropertyMap& other, const std::string& other_name)> InitializerFunction;
|
||||
typedef std::function<boost::any(const PropertyMap& other)> InitializerFunction;
|
||||
typedef std::map<PropertyInitializerSource, InitializerFunction> 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_;
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
#include <moveit/task_constructor/properties.h>
|
||||
#include <boost/format.hpp>
|
||||
#include <ros/console.h>
|
||||
#include <functional>
|
||||
|
||||
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_);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user