Remove most using declarations from header files.
[ardour.git] / libs / ardour / ardour / element_import_handler.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sakari Bergen
4
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.
9
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.
14
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.
18
19 */
20
21 #ifndef __ardour_element_import_handler_h__
22 #define __ardour_element_import_handler_h__
23
24 #include <string>
25 #include <list>
26 #include <set>
27
28 #include <boost/shared_ptr.hpp>
29
30 class XMLTree;
31
32 namespace ARDOUR {
33
34 class Session;
35 class ElementImporter;
36
37 /// Virtual interface class for element import handlers 
38 class ElementImportHandler
39 {
40   public:
41         typedef boost::shared_ptr<ElementImporter> ElementPtr;
42         typedef std::list<ElementPtr> ElementList;
43
44         /** ElementImportHandler constructor
45          * The constructor should find everything from the XML Tree it can handle
46          * and create respective Elements stored in elements.
47          *
48          * @param source XML tree to be parsed
49          * @see elements
50          */
51         ElementImportHandler (XMLTree const & source, ARDOUR::Session & session) :
52           source (source), session (session) { }
53         
54         virtual ~ElementImportHandler ();
55         
56         /** Gets a textual representation of the element type
57          * @return textual representation of element type
58          */
59         virtual std::string get_info () const = 0;
60         
61         /// Elements this handler handles
62         ElementList elements;
63         
64         /* For checking duplicates names against queued elements */
65         
66         /** Checks whether or not an element with some name is queued or not
67          * @param name name to check
68          * @return true if name is not used
69          */
70         bool check_name (const std::string & name) const;
71         
72         /// Adds name to the list of used names
73         void add_name (std::string name);
74         
75         /// Removes name from the list of used names
76         void remove_name (const std::string & name);
77         
78         /// Checks wheter or not all elements can be imported cleanly
79         static bool dirty () { return _dirty; }
80         
81         /// Sets handler dirty
82         static void set_dirty () { _dirty = true; }
83         
84         /// Checks wheter or not all elements were imported cleanly
85         static bool errors () { return _errors; }
86         
87         /// Sets handler dirty
88         static void set_errors () { _errors = true; }
89
90   protected:
91         /// Source session XML tree
92         XMLTree const &   source;
93         
94         /// Destination session
95         ARDOUR::Session & session;
96         
97         /// Session XML readability
98         static bool _dirty;
99         
100         /// Errors post initialization
101         static bool _errors;
102         
103   private:
104         /// Set of names for duplicate checking
105         std::set<std::string> names;
106 };
107
108 } // namespace ARDOUR
109
110 #endif