~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to libs/ardour/configuration.cc

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 1999-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 <iostream>
 
21
 
 
22
#include "pbd/compose.h"
 
23
 
 
24
#include "ardour/configuration.h"
 
25
#include "ardour/debug.h"
 
26
 
 
27
using namespace ARDOUR;
 
28
using namespace std;
 
29
using namespace PBD;
 
30
 
 
31
Configuration::Configuration ()
 
32
{
 
33
}
 
34
 
 
35
Configuration::~Configuration ()
 
36
{
 
37
}
 
38
 
 
39
void
 
40
ConfigVariableBase::add_to_node (XMLNode& node)
 
41
{
 
42
        const std::string v = get_as_string ();
 
43
        DEBUG_TRACE (DEBUG::Configuration, string_compose ("Config variable %1 stored as [%2]\n", _name, v));
 
44
        XMLNode* child = new XMLNode ("Option");
 
45
        child->add_property ("name", _name);
 
46
        child->add_property ("value", v);
 
47
        node.add_child_nocopy (*child);
 
48
}
 
49
 
 
50
bool
 
51
ConfigVariableBase::set_from_node (XMLNode const & node)
 
52
{
 
53
        if (node.name() == "Config" || node.name() == "Canvas" || node.name() == "UI") {
 
54
 
 
55
                /* ardour.rc */
 
56
 
 
57
                const XMLProperty* prop;
 
58
                XMLNodeList nlist;
 
59
                XMLNodeConstIterator niter;
 
60
                XMLNode* child;
 
61
 
 
62
                nlist = node.children();
 
63
 
 
64
                for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
 
65
 
 
66
                        child = *niter;
 
67
 
 
68
                        if (child->name() == "Option") {
 
69
                                if ((prop = child->property ("name")) != 0) {
 
70
                                        if (prop->value() == _name) {
 
71
                                                if ((prop = child->property ("value")) != 0) {
 
72
                                                        set_from_string (prop->value());
 
73
                                                        return true;
 
74
                                                }
 
75
                                        }
 
76
                                }
 
77
                        }
 
78
                }
 
79
 
 
80
        } else if (node.name() == "Options") {
 
81
 
 
82
                /* session file */
 
83
 
 
84
                XMLNodeList olist;
 
85
                XMLNodeConstIterator oiter;
 
86
                XMLNode* option;
 
87
                const XMLProperty* opt_prop;
 
88
 
 
89
                olist = node.children();
 
90
 
 
91
                for (oiter = olist.begin(); oiter != olist.end(); ++oiter) {
 
92
 
 
93
                        option = *oiter;
 
94
 
 
95
                        if (option->name() == _name) {
 
96
                                if ((opt_prop = option->property ("val")) != 0) {
 
97
                                        set_from_string (opt_prop->value());
 
98
                                        return true;
 
99
                                }
 
100
                        }
 
101
                }
 
102
        }
 
103
 
 
104
        return false;
 
105
}
 
106
 
 
107
void
 
108
ConfigVariableBase::notify ()
 
109
{
 
110
        // placeholder for any debugging desired when a config variable is modified
 
111
}
 
112
 
 
113
void
 
114
ConfigVariableBase::miss ()
 
115
{
 
116
        // placeholder for any debugging desired when a config variable
 
117
        // is set but to the same value as it already has
 
118
}
 
119