Move panner bypass state up to the PannerShell so that it is preserved even when...
[ardour2.git] / libs / ardour / session_configuration.cc
blob899b85e7701504aa0010b89113f857ddd278c86a
1 /*
2 Copyright (C) 2009 Paul Davis
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.
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.
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.
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"
26 using namespace ARDOUR;
27 using namespace PBD;
29 SessionConfiguration::SessionConfiguration ()
31 /* construct variables */
32 #undef CONFIG_VARIABLE
33 #undef CONFIG_VARIABLE_SPECIAL
34 #define CONFIG_VARIABLE(Type,var,name,value) var (name,value),
35 #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) var (name,value,mutator),
36 #include "ardour/session_configuration_vars.h"
37 #undef CONFIG_VARIABLE
38 #undef CONFIG_VARIABLE_SPECIAL
39 foo (0)
44 XMLNode&
45 SessionConfiguration::get_state ()
47 XMLNode* root;
48 LocaleGuard lg (X_("POSIX"));
50 root = new XMLNode ("Ardour");
51 root->add_child_nocopy (get_variables ());
53 return *root;
57 XMLNode&
58 SessionConfiguration::get_variables ()
60 XMLNode* node;
61 LocaleGuard lg (X_("POSIX"));
63 node = new XMLNode ("Config");
65 #undef CONFIG_VARIABLE
66 #undef CONFIG_VARIABLE_SPECIAL
67 #define CONFIG_VARIABLE(type,var,Name,value) \
68 var.add_to_node (*node);
69 #define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \
70 var.add_to_node (*node);
71 #include "ardour/session_configuration_vars.h"
72 #undef CONFIG_VARIABLE
73 #undef CONFIG_VARIABLE_SPECIAL
75 return *node;
79 int
80 SessionConfiguration::set_state (XMLNode const& root, int /*version*/)
82 if (root.name() != "Ardour") {
83 return -1;
86 for (XMLNodeConstIterator i = root.children().begin(); i != root.children().end(); ++i) {
87 if ((*i)->name() == "Config") {
88 set_variables (**i);
92 return 0;
95 void
96 SessionConfiguration::set_variables (const XMLNode& node)
98 #undef CONFIG_VARIABLE
99 #undef CONFIG_VARIABLE_SPECIAL
100 #define CONFIG_VARIABLE(type,var,name,value) \
101 if (var.set_from_node (node)) { \
102 ParameterChanged (name); \
104 #define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) \
105 if (var.set_from_node (node)) { \
106 ParameterChanged (name); \
109 #include "ardour/session_configuration_vars.h"
110 #undef CONFIG_VARIABLE
111 #undef CONFIG_VARIABLE_SPECIAL
114 void
115 SessionConfiguration::map_parameters (boost::function<void (std::string)>& functor)
117 #undef CONFIG_VARIABLE
118 #undef CONFIG_VARIABLE_SPECIAL
119 #define CONFIG_VARIABLE(type,var,name,value) functor (name);
120 #define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) functor (name);
121 #include "ardour/session_configuration_vars.h"
122 #undef CONFIG_VARIABLE
123 #undef CONFIG_VARIABLE_SPECIAL