fix crash when copy'ing latent plugins
[ardour.git] / libs / ardour / ardour / session_configuration.h
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 #ifndef __ardour_session_configuration_h__
21 #define __ardour_session_configuration_h__
22
23 #include "pbd/configuration.h"
24
25 namespace ARDOUR {
26
27 class LIBARDOUR_API SessionConfiguration : public PBD::Configuration
28 {
29 public:
30         SessionConfiguration ();
31
32         void map_parameters (boost::function<void (std::string)>&);
33         int set_state (XMLNode const &, int version);
34         XMLNode& get_state ();
35         XMLNode& get_variables ();
36         void set_variables (XMLNode const &);
37
38         bool load_state ();
39         bool save_state ();
40
41         /* define accessor methods */
42
43 #undef  CONFIG_VARIABLE
44 #undef  CONFIG_VARIABLE_SPECIAL
45 #define CONFIG_VARIABLE(Type,var,name,value) \
46         Type get_##var () const { return var.get(); } \
47         bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret;  }
48 #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) \
49         Type get_##var () const { return var.get(); } \
50         bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
51 #include "ardour/session_configuration_vars.h"
52 #undef  CONFIG_VARIABLE
53 #undef  CONFIG_VARIABLE_SPECIAL
54
55   private:
56
57         /* declare variables */
58
59 #undef  CONFIG_VARIABLE
60 #undef  CONFIG_VARIABLE_SPECIAL
61 #define CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable<Type> var;
62 #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) PBD::ConfigVariableWithMutation<Type> var;
63 #include "ardour/session_configuration_vars.h"
64 #undef  CONFIG_VARIABLE
65 #undef  CONFIG_VARIABLE_SPECIAL
66
67         int foo;
68 };
69
70 }
71
72 #endif