mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-04 20:55:48 +01:00
Insert_or_assign properties, allow to override properties
This allows to copy a property list and then selectively replace various properties. e.g. ``` PropertyList plist (region->properties ()); plist.add (Properties::length, len); plist.remove (Properties::start); ``` See also8b0ab38675and97f0fac7d5This also fixes the issue referenced in8c83149c4c
This commit is contained in:
parent
ddec1a9a98
commit
ebf59d4426
2 changed files with 8 additions and 1 deletions
|
|
@ -57,6 +57,7 @@ public:
|
|||
* Defined below, once we have Property<T>
|
||||
*/
|
||||
template<typename T, typename V> bool add (PropertyDescriptor<T> pid, const V& v);
|
||||
template<typename T> bool remove (PropertyDescriptor<T> pid);
|
||||
|
||||
protected:
|
||||
bool _property_owner;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,13 @@ namespace PBD {
|
|||
|
||||
template<typename T, typename V> bool
|
||||
PropertyList::add (PropertyDescriptor<T> pid, const V& v) {
|
||||
return insert (value_type (pid.property_id, new Property<T> (pid, (T)v))).second;
|
||||
erase (pid.property_id);
|
||||
return insert (value_type (pid.property_id, new Property<T> (pid, (T)v))).second;
|
||||
}
|
||||
|
||||
template<typename T> bool
|
||||
PropertyList::remove (PropertyDescriptor<T> pid) {
|
||||
return erase (pid.property_id) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue