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>
34 #include <pbd/file_utils.h>
35 #include <pbd/xml++.h>
37 #include <ardour/filesystem_paths.h>
38 #include <ardour/location.h>
39 #include <ardour/types.h>
50 class ExportChannelConfiguration;
51 class ExportFormatSpecification;
56 /// Manages (de)serialization of export profiles and related classes
57 class ExportProfileManager
62 Preset (string filename, Session & s);
65 uint32_t id () const { return _id; }
66 string name () const { return _name; }
68 void set_name (string name);
69 void set_id (uint32_t id);
71 // Note: The set_..._state functions take ownership of the XMLNode
72 void set_global_state (XMLNode & state);
73 void set_local_state (XMLNode & state);
75 XMLNode const * get_global_state () const { return global.root(); }
76 XMLNode const * get_local_state () const { return local; }
79 void remove_local () const;
83 XMLNode * get_instant_xml () const;
84 void save_instant_xml () const;
85 void remove_instant_xml () const;
96 typedef boost::shared_ptr<Preset> PresetPtr;
97 typedef std::list<PresetPtr> PresetList;
101 ExportProfileManager (Session & s);
102 ~ExportProfileManager ();
104 void load_profile ();
105 void prepare_for_export ();
107 PresetList const & get_presets () { return preset_list; }
108 void load_preset (PresetPtr preset);
109 PresetPtr save_preset (string const & name);
110 void remove_preset ();
113 typedef boost::shared_ptr<ExportHandler> HandlerPtr;
115 typedef std::pair<uint32_t, PBD::sys::path> FilePair;
116 typedef std::map<uint32_t, PBD::sys::path> FileMap;
121 void load_presets ();
122 uint32_t load_preset_from_disk (PBD::sys::path const & path); // Returns preset id
124 void set_state (XMLNode const & root);
125 void set_global_state (XMLNode const & root);
126 void set_local_state (XMLNode const & root);
128 void serialize_profile (XMLNode & root);
129 void serialize_global_profile (XMLNode & root);
130 void serialize_local_profile (XMLNode & root);
132 PresetList preset_list;
133 PresetPtr current_preset;
134 uint32_t preset_id_counter;
135 FileMap preset_file_map;
137 std::vector<PBD::sys::path> find_file (std::string const & pattern);
139 PBD::sys::path export_config_dir;
140 PBD::SearchPath search_path;
145 typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
146 typedef std::list<TimespanPtr> TimespanList;
147 typedef boost::shared_ptr<TimespanList> TimespanListPtr;
148 typedef std::list<Location *> LocationList;
158 struct TimespanState {
159 TimespanListPtr timespans;
160 TimeFormat time_format;
162 boost::shared_ptr<Location> session_range;
163 boost::shared_ptr<Location> selection_range;
164 boost::shared_ptr<LocationList> ranges;
166 TimespanState (boost::shared_ptr<Location> session_range,
167 boost::shared_ptr<Location> selection_range,
168 boost::shared_ptr<LocationList> ranges) :
169 timespans (new TimespanList ()),
172 session_range (session_range),
173 selection_range (selection_range),
178 typedef boost::shared_ptr<TimespanState> TimespanStatePtr;
179 typedef std::list<TimespanStatePtr> TimespanStateList;
181 void set_selection_range (nframes_t start = 0, nframes_t end = 0);
182 TimespanStateList const & get_timespans () { return timespans; }
186 TimespanStateList timespans;
188 void init_timespans (XMLNodeList nodes);
190 TimespanStatePtr deserialize_timespan (XMLNode & root);
191 XMLNode & serialize_timespan (TimespanStatePtr state);
195 void update_ranges ();
197 boost::shared_ptr<Location> session_range;
198 boost::shared_ptr<Location> selection_range;
199 boost::shared_ptr<LocationList> ranges;
201 /* Channel Configs */
204 typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
206 struct ChannelConfigState {
207 ChannelConfigPtr config;
209 ChannelConfigState (ChannelConfigPtr ptr) : config (ptr) {}
211 typedef boost::shared_ptr<ChannelConfigState> ChannelConfigStatePtr;
212 typedef std::list<ChannelConfigStatePtr> ChannelConfigStateList;
214 ChannelConfigStateList const & get_channel_configs () { return channel_configs; }
218 ChannelConfigStateList channel_configs;
220 void init_channel_configs (XMLNodeList nodes);
222 ChannelConfigStatePtr deserialize_channel_config (XMLNode & root);
223 XMLNode & serialize_channel_config (ChannelConfigStatePtr state);
228 typedef boost::shared_ptr<ExportFormatSpecification> FormatPtr;
229 typedef std::list<FormatPtr> FormatList;
232 boost::shared_ptr<FormatList const> list;
235 FormatState (boost::shared_ptr<FormatList const> list, FormatPtr format) :
236 list (list), format (format) {}
238 typedef boost::shared_ptr<FormatState> FormatStatePtr;
239 typedef std::list<FormatStatePtr> FormatStateList;
241 FormatStateList const & get_formats () { return formats; }
242 FormatStatePtr duplicate_format_state (FormatStatePtr state);
243 void remove_format_state (FormatStatePtr state);
245 PBD::sys::path save_format_to_disk (FormatPtr format);
246 void remove_format_profile (FormatPtr format);
247 FormatPtr get_new_format (FormatPtr original);
249 sigc::signal<void> FormatListChanged;
253 FormatStateList formats;
255 void init_formats (XMLNodeList nodes);
256 FormatStatePtr deserialize_format (XMLNode & root);
257 XMLNode & serialize_format (FormatStatePtr state);
259 void load_formats ();
261 FormatPtr load_format (XMLNode & node);
262 void load_format_from_disk (PBD::sys::path const & path);
264 boost::shared_ptr<FormatList> format_list;
265 FileMap format_file_map;
270 typedef boost::shared_ptr<ExportFilename> FilenamePtr;
272 struct FilenameState {
273 FilenamePtr filename;
275 FilenameState (FilenamePtr ptr) : filename (ptr) {}
277 typedef boost::shared_ptr<FilenameState> FilenameStatePtr;
278 typedef std::list<FilenameStatePtr> FilenameStateList;
280 FilenameStateList const & get_filenames () { return filenames; }
281 FilenameStatePtr duplicate_filename_state (FilenameStatePtr state);
282 void remove_filename_state (FilenameStatePtr state);
286 FilenameStateList filenames;
288 void init_filenames (XMLNodeList nodes);
290 FilenameStatePtr deserialize_filename (XMLNode & root);
291 XMLNode & serialize_filename (FilenameStatePtr state);
293 FilenamePtr load_filename (XMLNode & node);
298 std::list<Glib::ustring> errors;
299 std::list<Glib::ustring> warnings;
300 std::list<Glib::ustring> conflicting_filenames;
303 boost::shared_ptr<Warnings> get_warnings ();
306 void check_config (boost::shared_ptr<Warnings> warnings,
307 TimespanStatePtr timespan_state,
308 ChannelConfigStatePtr channel_config_state,
309 FormatStatePtr format_state,
310 FilenameStatePtr filename_state);
314 } // namespace ARDOUR
316 #endif /* __ardour_export_profile_manager_h__ */