diff --git a/core/include/moveit/task_constructor/properties.h b/core/include/moveit/task_constructor/properties.h index cbc4e79e..7ceeda2a 100644 --- a/core/include/moveit/task_constructor/properties.h +++ b/core/include/moveit/task_constructor/properties.h @@ -72,6 +72,8 @@ public: typedef int SourceId; /// function callback used to initialize property value from another PropertyMap typedef std::function InitializerFunction; + /// function callback used to signal value setting to external components + typedef std::function SignalFunction; /// set current value and default value void setValue(const boost::any& value); @@ -100,6 +102,10 @@ public: /// set current value using matching configured initializers void performInitFrom(SourceId source, const PropertyMap& other); + /// define a function callback to be called on each value update + /// note, that boost::any doesn't allow for change detection + void setSignalCallback(const SignalFunction& f) { signaller_ = f; } + private: std::string description_; std::type_index type_index_; @@ -109,6 +115,7 @@ private: /// used for external initialization SourceId source_id_ = 0; InitializerFunction initializer_; + SignalFunction signaller_; }; diff --git a/core/src/properties.cpp b/core/src/properties.cpp index 524a9c61..0e9b324e 100644 --- a/core/src/properties.cpp +++ b/core/src/properties.cpp @@ -73,6 +73,8 @@ void Property::setCurrentValue(const boost::any &value) if (!value.empty()) typeCheck(value, type_index_); value_ = value; + if (signaller_) + signaller_(this); } void Property::reset()