mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
signal callback function
... to allow for syncing with rviz::Property
This commit is contained in:
parent
c3eead0115
commit
5ff78f653e
@ -72,6 +72,8 @@ public:
|
|||||||
typedef int SourceId;
|
typedef int SourceId;
|
||||||
/// function callback used to initialize property value from another PropertyMap
|
/// function callback used to initialize property value from another PropertyMap
|
||||||
typedef std::function<boost::any(const PropertyMap& other)> InitializerFunction;
|
typedef std::function<boost::any(const PropertyMap& other)> InitializerFunction;
|
||||||
|
/// function callback used to signal value setting to external components
|
||||||
|
typedef std::function<void(const Property*)> SignalFunction;
|
||||||
|
|
||||||
/// set current value and default value
|
/// set current value and default value
|
||||||
void setValue(const boost::any& value);
|
void setValue(const boost::any& value);
|
||||||
@ -100,6 +102,10 @@ public:
|
|||||||
/// set current value using matching configured initializers
|
/// set current value using matching configured initializers
|
||||||
void performInitFrom(SourceId source, const PropertyMap& other);
|
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:
|
private:
|
||||||
std::string description_;
|
std::string description_;
|
||||||
std::type_index type_index_;
|
std::type_index type_index_;
|
||||||
@ -109,6 +115,7 @@ private:
|
|||||||
/// used for external initialization
|
/// used for external initialization
|
||||||
SourceId source_id_ = 0;
|
SourceId source_id_ = 0;
|
||||||
InitializerFunction initializer_;
|
InitializerFunction initializer_;
|
||||||
|
SignalFunction signaller_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,6 +73,8 @@ void Property::setCurrentValue(const boost::any &value)
|
|||||||
if (!value.empty())
|
if (!value.empty())
|
||||||
typeCheck(value, type_index_);
|
typeCheck(value, type_index_);
|
||||||
value_ = value;
|
value_ = value;
|
||||||
|
if (signaller_)
|
||||||
|
signaller_(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Property::reset()
|
void Property::reset()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user