ardour
property_list.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #include "pbd/debug.h"
21 #include "pbd/compose.h"
22 #include "pbd/property_list.h"
23 #include "pbd/xml++.h"
24 
25 using namespace PBD;
26 
28  : _property_owner (true)
29 {
30 
31 }
32 
34  : std::map<PropertyID, PropertyBase*> (other)
35  , _property_owner (other._property_owner)
36 {
37  if (_property_owner) {
38  /* make our own copies of the properties */
39  clear ();
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 ()));
42  }
43  }
44 }
45 
47 {
48  if (_property_owner) {
49  for (iterator i = begin (); i != end (); ++i) {
50  delete i->second;
51  }
52  }
53 }
54 
55 void
57 {
58  for (const_iterator i = begin(); i != end(); ++i) {
59  DEBUG_TRACE (DEBUG::Properties, string_compose ("Add changes to %1 for %2\n",
60  history_node->name(),
61  i->second->property_name()));
62  i->second->get_changes_as_xml (history_node);
63  }
64 }
65 
66 bool
68 {
69  return insert (value_type (prop->property_id(), prop)).second;
70 }
71 
72 void
74 {
75  for (iterator i = begin(); i != end(); ++i) {
76  i->second->invert ();
77  }
78 }
79 
81 {
82  _property_owner = false;
83 }
84 
85 bool
87 {
88  return insert (value_type (p.property_id (), &p)).second;
89 }
90 
91 
const std::string & name() const
Definition: xml++.h:104
Definition: Beats.hpp:239
virtual ~PropertyList()
GQuark PropertyID
PropertyID property_id() const
#define DEBUG_TRACE(bits, str)
Definition: debug.h:55
void get_changes_as_xml(XMLNode *)
LIBPBD_API uint64_t Properties
Definition: debug.cc:47
Definition: xml++.h:95
Definition: debug.h:30
bool add(PropertyBase *prop)
std::string string_compose(const std::string &fmt, const T1 &o1)
Definition: compose.h:208
bool add(PropertyBase &p)