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 #ifndef __ardour_element_import_handler_h__
22 #define __ardour_element_import_handler_h__
28 #include <boost/shared_ptr.hpp>
30 #include "ardour/libardour_visibility.h"
31 #include "pbd/libpbd_visibility.h"
38 class ElementImporter;
40 /// Virtual interface class for element import handlers
41 class LIBARDOUR_API ElementImportHandler
44 typedef boost::shared_ptr<ElementImporter> ElementPtr;
45 typedef std::list<ElementPtr> ElementList;
47 /** ElementImportHandler constructor
48 * The constructor should find everything from the XML Tree it can handle
49 * and create respective Elements stored in elements.
51 * @param source XML tree to be parsed
54 ElementImportHandler (XMLTree const & source, ARDOUR::Session & session)
55 : source (source), session (session) { }
57 virtual ~ElementImportHandler ();
59 /** Gets a textual representation of the element type
60 * @return textual representation of element type
62 virtual std::string get_info () const = 0;
64 /// Elements this handler handles
67 /* For checking duplicates names against queued elements */
69 /** Checks whether or not an element with some name is queued or not
70 * @param name name to check
71 * @return true if name is not used
73 bool check_name (const std::string & name) const;
75 /// Adds name to the list of used names
76 void add_name (std::string name);
78 /// Removes name from the list of used names
79 void remove_name (const std::string & name);
81 /// Checks wheter or not all elements can be imported cleanly
82 static bool dirty () { return _dirty; }
84 /// Sets handler dirty
85 static void set_dirty () { _dirty = true; }
87 /// Checks wheter or not all elements were imported cleanly
88 static bool errors () { return _errors; }
90 /// Sets handler dirty
91 static void set_errors () { _errors = true; }
94 /// Source session XML tree
95 XMLTree const & source;
97 /// Destination session
98 ARDOUR::Session & session;
100 /// Session XML readability
103 /// Errors post initialization
107 /// Set of names for duplicate checking
108 std::set<std::string> names;
111 } // namespace ARDOUR