Prefer vfork() over system() when opening an URI
[ardour.git] / libs / pbd / pbd / property_list.h
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 #ifndef __pbd_property_list_h__
21 #define __pbd_property_list_h__
22
23 #include <map>
24
25 #include "pbd/libpbd_visibility.h"
26 #include "pbd/property_basics.h"
27
28 class XMLNode;
29
30 namespace PBD {
31
32 /** A list of properties, mapped using their ID */
33 class LIBPBD_API PropertyList : public std::map<PropertyID, PropertyBase*>
34 {
35 public:
36         PropertyList ();
37         PropertyList (PropertyList const &);
38
39         virtual ~PropertyList();
40
41         void get_changes_as_xml (XMLNode*);
42         void invert ();
43
44         /** Add a property (of some kind) to the list.
45          *
46          * Used when
47          * constructing PropertyLists that describe a change/operation.
48          */
49         bool add (PropertyBase* prop);
50
51         /** Construct a new Property List
52          *
53          * Code that is constructing a property list for use
54          * in setting the state of an object uses this.
55          *
56          * Defined below, once we have Property<T>
57          */
58         template<typename T, typename V> bool add (PropertyDescriptor<T> pid, const V& v);
59
60 protected:
61         bool _property_owner;
62 };
63
64 /** Persistent Property List
65  *
66  * A variant of PropertyList that does not delete its
67  * property list in its destructor. Objects with their
68  * own Properties store them in an OwnedPropertyList
69  * to avoid having them deleted at the wrong time.
70  */
71 class LIBPBD_API OwnedPropertyList : public PropertyList
72 {
73 public:
74         OwnedPropertyList();
75
76         /** Add a property to the List
77          *
78          * Classes that own property lists use this to add their
79          * property members to their plists. Note that it takes
80          * a reference argument rather than a pointer like
81          * one of the add() methods in PropertyList.
82          */
83         bool add (PropertyBase& p);
84 };
85
86 }
87
88 #endif /* __pbd_property_list_h__ */