2 Copyright (C) 2008 Paul Davis
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
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <ardour/audio_track_importer.h>
24 #include <pbd/failed_constructor.h>
30 /*** AudioTrackImportHandler ***/
32 AudioTrackImportHandler::AudioTrackImportHandler (XMLTree const & source, Session & session) :
33 ElementImportHandler (source, session)
35 XMLNode const * root = source.root();
36 XMLNode const * routes;
38 if (!(routes = root->child ("Routes"))) {
39 throw failed_constructor();
42 XMLNodeList const & route_list = routes->children();
43 for (XMLNodeList::const_iterator it = route_list.begin(); it != route_list.end(); ++it) {
44 const XMLProperty* type = (*it)->property("default-type");
45 if ( !type || type->value() == "audio" ) {
47 elements.push_back (ElementPtr ( new AudioTrackImporter (source, session, *this, **it)));
48 } catch (failed_constructor err) {
56 AudioTrackImportHandler::get_info () const
58 return _("Audio Tracks");
62 /*** AudioTrackImporter ***/
64 AudioTrackImporter::AudioTrackImporter (XMLTree const & source, Session & session, AudioTrackImportHandler & handler, XMLNode const & node) :
65 ElementImporter (source, session),
68 // TODO Parse top-level XML
70 if (!parse_io (node)) {
71 throw failed_constructor();
74 XMLNodeList const & controllables = node.children ("controllable");
75 for (XMLNodeList::const_iterator it = controllables.begin(); it != controllables.end(); ++it) {
76 parse_controllable (**it, xml_track);
79 // TODO parse remote-control and extra?
84 AudioTrackImporter::get_info () const
91 AudioTrackImporter::prepare_move ()
98 AudioTrackImporter::cancel_move ()
104 AudioTrackImporter::move ()
110 AudioTrackImporter::parse_io (XMLNode const & node)
115 if (!(io = node.child ("IO"))) {
119 if ((prop = io->property ("name"))) {
120 name = prop->value();
125 // TODO parse rest of the XML
131 AudioTrackImporter::parse_controllable (XMLNode const & node, XMLNode & dest_parent)
134 XMLNode new_node (node);
136 if ((prop = new_node.property ("id"))) {
137 PBD::ID old_id (prop->value());
140 prop->set_value (new_id.to_s());
141 // TODO do id mapping and everything else necessary...
147 dest_parent.add_child_copy (new_node);
152 } // namespace ARDOUR