2 * Copyright (C) 2010-2015 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2010 Carl Hetherington <carl@carlh.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "pbd/debug.h"
21 #include "pbd/compose.h"
22 #include "pbd/property_list.h"
23 #include "pbd/xml++.h"
27 PropertyList::PropertyList()
28 : _property_owner (true)
33 PropertyList::PropertyList (PropertyList const & other)
34 : std::map<PropertyID, PropertyBase*> (other)
35 , _property_owner (other._property_owner)
37 if (_property_owner) {
38 /* make our own copies of the properties */
40 for (std::map<PropertyID, PropertyBase*>::const_iterator i = other.begin(); i != other.end(); ++i) {
41 insert (std::make_pair (i->first, i->second->clone ()));
46 PropertyList::~PropertyList ()
48 if (_property_owner) {
49 for (iterator i = begin (); i != end (); ++i) {
56 PropertyList::get_changes_as_xml (XMLNode* history_node)
58 for (const_iterator i = begin(); i != end(); ++i) {
59 DEBUG_TRACE (DEBUG::Properties, string_compose ("Add changes to %1 for %2\n",
61 i->second->property_name()));
62 i->second->get_changes_as_xml (history_node);
67 PropertyList::add (PropertyBase* prop)
69 return insert (value_type (prop->property_id(), prop)).second;
73 PropertyList::invert ()
75 for (iterator i = begin(); i != end(); ++i) {
80 OwnedPropertyList::OwnedPropertyList ()
82 _property_owner = false;
86 OwnedPropertyList::add (PropertyBase& p)
88 return insert (value_type (p.property_id (), &p)).second;