2 * Copyright (C) 2006-2009 David Robillard <d@drobilla.net>
3 * Copyright (C) 2008-2016 Paul Davis <paul@linuxaudiosystems.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "ardour/chan_count.h"
22 #include "ardour/types_convert.h"
26 static const char* state_node_name = "Channels";
32 // infinite/zero chan count stuff, for setting minimums and maximums, etc.
33 // FIXME: implement this in a less fugly way
35 ChanCount::ChanCount(const XMLNode& node)
38 XMLNodeConstIterator iter = node.children().begin();
39 for ( ; iter != node.children().end(); ++iter) {
40 if ((*iter)->name() == X_(state_node_name)) {
41 DataType type (DataType::NIL);
43 if ((*iter)->get_property ("type", type) && (*iter)->get_property ("count", count)) {
51 ChanCount::state(const std::string& name) const
53 XMLNode* node = new XMLNode (name);
54 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
55 uint32_t count = get(*t);
57 XMLNode* n = new XMLNode(X_(state_node_name));
58 n->set_property("type", *t);
59 n->set_property("count", count);
60 node->add_child_nocopy(*n);
67 const ChanCount ChanCount::ZERO = ChanCount();
71 std::ostream& operator<<(std::ostream& o, const ARDOUR::ChanCount& c) {
72 return o << "AUDIO=" << c.n_audio() << ":MIDI=" << c.n_midi();