Fix unused parameter warnings since GCC apparently doesn't feel like listening to...
[ardour.git] / libs / ardour / session_configuration.cc
1 /*
2     Copyright (C) 2009 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 "ardour/types.h"
21 #include "ardour/utils.h"
22 #include "ardour/session_configuration.h"
23 #include "ardour/ardour.h"
24 #include "i18n.h"
25
26 using namespace ARDOUR;
27
28 SessionConfiguration::SessionConfiguration ()
29         :
30 /* construct variables */
31 #undef  CONFIG_VARIABLE
32 #undef  CONFIG_VARIABLE_SPECIAL
33 #define CONFIG_VARIABLE(Type,var,name,value) var (name,value),
34 #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) var (name,value,mutator),
35 #include "ardour/session_configuration_vars.h"
36 #undef  CONFIG_VARIABLE
37 #undef  CONFIG_VARIABLE_SPECIAL
38         foo (0)
39 {
40
41 }
42
43 XMLNode&
44 SessionConfiguration::get_state ()
45 {
46         XMLNode* root;
47         LocaleGuard lg (X_("POSIX"));
48
49         root = new XMLNode ("Ardour");
50         root->add_child_nocopy (get_variables ());
51
52         return *root;
53 }
54
55
56 XMLNode&
57 SessionConfiguration::get_variables ()
58 {
59         XMLNode* node;
60         LocaleGuard lg (X_("POSIX"));
61
62         node = new XMLNode ("Config");
63
64 #undef  CONFIG_VARIABLE
65 #undef  CONFIG_VARIABLE_SPECIAL
66 #define CONFIG_VARIABLE(type,var,Name,value) \
67         var.add_to_node (*node);
68 #define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \
69         var.add_to_node (*node);
70 #include "ardour/session_configuration_vars.h"
71 #undef  CONFIG_VARIABLE
72 #undef  CONFIG_VARIABLE_SPECIAL
73
74         return *node;
75 }
76
77
78 int
79 SessionConfiguration::set_state (XMLNode const& root, int /*version*/)
80 {
81         if (root.name() != "Ardour") {
82                 return -1;
83         }
84
85         for (XMLNodeConstIterator i = root.children().begin(); i != root.children().end(); ++i) {
86                 if ((*i)->name() == "Config") {
87                         set_variables (**i);
88                 }
89         }
90
91         return 0;
92 }
93
94 void
95 SessionConfiguration::set_variables (const XMLNode& node)
96 {
97 #undef  CONFIG_VARIABLE
98 #undef  CONFIG_VARIABLE_SPECIAL
99 #define CONFIG_VARIABLE(type,var,name,value) \
100         if (var.set_from_node (node)) { \
101                 ParameterChanged (name);                  \
102         }
103 #define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) \
104         if (var.set_from_node (node)) {    \
105                 ParameterChanged (name);                     \
106         }
107
108 #include "ardour/session_configuration_vars.h"
109 #undef  CONFIG_VARIABLE
110 #undef  CONFIG_VARIABLE_SPECIAL
111
112 }
113 void
114 SessionConfiguration::map_parameters (sigc::slot<void, std::string> theSlot)
115 {
116 #undef  CONFIG_VARIABLE
117 #undef  CONFIG_VARIABLE_SPECIAL
118 #define CONFIG_VARIABLE(type,var,name,value)                 theSlot (name);
119 #define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) theSlot (name);
120 #include "ardour/session_configuration_vars.h"
121 #undef  CONFIG_VARIABLE
122 #undef  CONFIG_VARIABLE_SPECIAL
123 }