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_export_profile_manager_h__
22 #define __ardour_export_profile_manager_h__
29 #include <boost/shared_ptr.hpp>
30 #include <boost/weak_ptr.hpp>
31 #include <sigc++/signal.h>
32 #include <glibmm/ustring.h>
35 #include <pbd/file_utils.h>
36 #include <pbd/xml++.h>
38 #include <ardour/filesystem_paths.h>
39 #include <ardour/location.h>
40 #include <ardour/types.h>
51 class ExportChannelConfiguration;
52 class ExportFormatSpecification;
58 /// Manages (de)serialization of export profiles and related classes
59 class ExportProfileManager
63 ExportProfileManager (Session & s);
64 ~ExportProfileManager ();
67 void prepare_for_export ();
69 typedef boost::shared_ptr<ExportPreset> PresetPtr;
70 typedef std::list<PresetPtr> PresetList;
72 PresetList const & get_presets () { return preset_list; }
73 bool load_preset (PresetPtr preset);
74 PresetPtr save_preset (string const & name);
75 void remove_preset ();
78 typedef boost::shared_ptr<ExportHandler> HandlerPtr;
80 typedef std::pair<PBD::UUID, PBD::sys::path> FilePair;
81 typedef std::map<PBD::UUID, PBD::sys::path> FileMap;
87 void load_preset_from_disk (PBD::sys::path const & path);
89 bool set_state (XMLNode const & root);
90 bool set_global_state (XMLNode const & root);
91 bool set_local_state (XMLNode const & root);
93 void serialize_profile (XMLNode & root);
94 void serialize_global_profile (XMLNode & root);
95 void serialize_local_profile (XMLNode & root);
97 PresetList preset_list;
98 PresetPtr current_preset;
99 FileMap preset_file_map;
101 std::vector<PBD::sys::path> find_file (std::string const & pattern);
103 PBD::sys::path export_config_dir;
104 PBD::SearchPath search_path;
109 typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
110 typedef std::list<TimespanPtr> TimespanList;
111 typedef boost::shared_ptr<TimespanList> TimespanListPtr;
112 typedef std::list<Location *> LocationList;
122 struct TimespanState {
123 TimespanListPtr timespans;
124 TimeFormat time_format;
126 boost::shared_ptr<Location> session_range;
127 boost::shared_ptr<Location> selection_range;
128 boost::shared_ptr<LocationList> ranges;
130 TimespanState (boost::shared_ptr<Location> session_range,
131 boost::shared_ptr<Location> selection_range,
132 boost::shared_ptr<LocationList> ranges) :
133 timespans (new TimespanList ()),
136 session_range (session_range),
137 selection_range (selection_range),
142 typedef boost::shared_ptr<TimespanState> TimespanStatePtr;
143 typedef std::list<TimespanStatePtr> TimespanStateList;
145 void set_selection_range (nframes_t start = 0, nframes_t end = 0);
146 TimespanStateList const & get_timespans () { return timespans; }
150 TimespanStateList timespans;
152 bool init_timespans (XMLNodeList nodes);
154 TimespanStatePtr deserialize_timespan (XMLNode & root);
155 XMLNode & serialize_timespan (TimespanStatePtr state);
159 void update_ranges ();
161 boost::shared_ptr<Location> session_range;
162 boost::shared_ptr<Location> selection_range;
163 boost::shared_ptr<LocationList> ranges;
165 /* Channel Configs */
168 typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
170 struct ChannelConfigState {
171 ChannelConfigPtr config;
173 ChannelConfigState (ChannelConfigPtr ptr) : config (ptr) {}
175 typedef boost::shared_ptr<ChannelConfigState> ChannelConfigStatePtr;
176 typedef std::list<ChannelConfigStatePtr> ChannelConfigStateList;
178 ChannelConfigStateList const & get_channel_configs () { return channel_configs; }
182 ChannelConfigStateList channel_configs;
184 bool init_channel_configs (XMLNodeList nodes);
189 typedef boost::shared_ptr<ExportFormatSpecification> FormatPtr;
190 typedef std::list<FormatPtr> FormatList;
193 boost::shared_ptr<FormatList const> list;
196 FormatState (boost::shared_ptr<FormatList const> list, FormatPtr format) :
197 list (list), format (format) {}
199 typedef boost::shared_ptr<FormatState> FormatStatePtr;
200 typedef std::list<FormatStatePtr> FormatStateList;
202 FormatStateList const & get_formats () { return formats; }
203 FormatStatePtr duplicate_format_state (FormatStatePtr state);
204 void remove_format_state (FormatStatePtr state);
206 PBD::sys::path save_format_to_disk (FormatPtr format);
207 void remove_format_profile (FormatPtr format);
208 FormatPtr get_new_format (FormatPtr original);
210 sigc::signal<void> FormatListChanged;
214 FormatStateList formats;
216 bool init_formats (XMLNodeList nodes);
217 FormatStatePtr deserialize_format (XMLNode & root);
218 XMLNode & serialize_format (FormatStatePtr state);
220 void load_formats ();
222 FormatPtr load_format (XMLNode & node);
223 void load_format_from_disk (PBD::sys::path const & path);
225 boost::shared_ptr<FormatList> format_list;
226 FileMap format_file_map;
231 typedef boost::shared_ptr<ExportFilename> FilenamePtr;
233 struct FilenameState {
234 FilenamePtr filename;
236 FilenameState (FilenamePtr ptr) : filename (ptr) {}
238 typedef boost::shared_ptr<FilenameState> FilenameStatePtr;
239 typedef std::list<FilenameStatePtr> FilenameStateList;
241 FilenameStateList const & get_filenames () { return filenames; }
242 FilenameStatePtr duplicate_filename_state (FilenameStatePtr state);
243 void remove_filename_state (FilenameStatePtr state);
247 FilenameStateList filenames;
249 bool init_filenames (XMLNodeList nodes);
250 FilenamePtr load_filename (XMLNode & node);
255 std::list<Glib::ustring> errors;
256 std::list<Glib::ustring> warnings;
257 std::list<Glib::ustring> conflicting_filenames;
260 boost::shared_ptr<Warnings> get_warnings ();
263 void check_config (boost::shared_ptr<Warnings> warnings,
264 TimespanStatePtr timespan_state,
265 ChannelConfigStatePtr channel_config_state,
266 FormatStatePtr format_state,
267 FilenameStatePtr filename_state);
271 } // namespace ARDOUR
273 #endif /* __ardour_export_profile_manager_h__ */