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__
30 #include <boost/shared_ptr.hpp>
31 #include <boost/weak_ptr.hpp>
32 #include <sigc++/signal.h>
33 #include <glibmm/ustring.h>
36 #include <pbd/file_utils.h>
37 #include <pbd/xml++.h>
39 #include <ardour/filesystem_paths.h>
40 #include <ardour/location.h>
41 #include <ardour/types.h>
52 class ExportChannelConfiguration;
53 class ExportFormatSpecification;
59 /// Manages (de)serialization of export profiles and related classes
60 class ExportProfileManager
64 ExportProfileManager (Session & s);
65 ~ExportProfileManager ();
68 void prepare_for_export ();
70 typedef boost::shared_ptr<ExportPreset> PresetPtr;
71 typedef std::list<PresetPtr> PresetList;
73 PresetList const & get_presets () { return preset_list; }
74 bool load_preset (PresetPtr preset);
75 PresetPtr save_preset (string const & name);
76 void remove_preset ();
79 typedef boost::shared_ptr<ExportHandler> HandlerPtr;
81 typedef std::pair<PBD::UUID, PBD::sys::path> FilePair;
82 typedef std::map<PBD::UUID, PBD::sys::path> FileMap;
88 void load_preset_from_disk (PBD::sys::path const & path);
90 bool set_state (XMLNode const & root);
91 bool set_global_state (XMLNode const & root);
92 bool set_local_state (XMLNode const & root);
94 void serialize_profile (XMLNode & root);
95 void serialize_global_profile (XMLNode & root);
96 void serialize_local_profile (XMLNode & root);
98 PresetList preset_list;
99 PresetPtr current_preset;
100 FileMap preset_file_map;
102 std::vector<PBD::sys::path> find_file (std::string const & pattern);
104 PBD::sys::path export_config_dir;
105 PBD::SearchPath search_path;
110 typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
111 typedef std::list<TimespanPtr> TimespanList;
112 typedef boost::shared_ptr<TimespanList> TimespanListPtr;
113 typedef std::list<Location *> LocationList;
123 struct TimespanState {
124 TimespanListPtr timespans;
125 TimeFormat time_format;
127 boost::shared_ptr<Location> session_range;
128 boost::shared_ptr<Location> selection_range;
129 boost::shared_ptr<LocationList> ranges;
131 TimespanState (boost::shared_ptr<Location> session_range,
132 boost::shared_ptr<Location> selection_range,
133 boost::shared_ptr<LocationList> ranges) :
134 timespans (new TimespanList ()),
137 session_range (session_range),
138 selection_range (selection_range),
143 typedef boost::shared_ptr<TimespanState> TimespanStatePtr;
144 typedef std::list<TimespanStatePtr> TimespanStateList;
146 void set_selection_range (nframes_t start = 0, nframes_t end = 0);
147 TimespanStateList const & get_timespans () { return check_list (timespans); }
151 TimespanStateList timespans;
153 bool init_timespans (XMLNodeList nodes);
155 TimespanStatePtr deserialize_timespan (XMLNode & root);
156 XMLNode & serialize_timespan (TimespanStatePtr state);
160 void update_ranges ();
162 boost::shared_ptr<Location> session_range;
163 boost::shared_ptr<Location> selection_range;
164 boost::shared_ptr<LocationList> ranges;
166 /* Channel Configs */
169 typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
171 struct ChannelConfigState {
172 ChannelConfigPtr config;
174 ChannelConfigState (ChannelConfigPtr ptr) : config (ptr) {}
176 typedef boost::shared_ptr<ChannelConfigState> ChannelConfigStatePtr;
177 typedef std::list<ChannelConfigStatePtr> ChannelConfigStateList;
179 ChannelConfigStateList const & get_channel_configs () { return check_list (channel_configs); }
183 ChannelConfigStateList channel_configs;
185 bool init_channel_configs (XMLNodeList nodes);
190 typedef boost::shared_ptr<ExportFormatSpecification> FormatPtr;
191 typedef std::list<FormatPtr> FormatList;
194 boost::shared_ptr<FormatList const> list;
197 FormatState (boost::shared_ptr<FormatList const> list, FormatPtr format) :
198 list (list), format (format) {}
200 typedef boost::shared_ptr<FormatState> FormatStatePtr;
201 typedef std::list<FormatStatePtr> FormatStateList;
203 FormatStateList const & get_formats () { return check_list (formats); }
204 FormatStatePtr duplicate_format_state (FormatStatePtr state);
205 void remove_format_state (FormatStatePtr state);
207 PBD::sys::path save_format_to_disk (FormatPtr format);
208 void remove_format_profile (FormatPtr format);
209 FormatPtr get_new_format (FormatPtr original);
211 sigc::signal<void> FormatListChanged;
215 FormatStateList formats;
217 bool init_formats (XMLNodeList nodes);
218 FormatStatePtr deserialize_format (XMLNode & root);
219 XMLNode & serialize_format (FormatStatePtr state);
221 void load_formats ();
223 FormatPtr load_format (XMLNode & node);
224 void load_format_from_disk (PBD::sys::path const & path);
226 boost::shared_ptr<FormatList> format_list;
227 FileMap format_file_map;
232 typedef boost::shared_ptr<ExportFilename> FilenamePtr;
234 struct FilenameState {
235 FilenamePtr filename;
237 FilenameState (FilenamePtr ptr) : filename (ptr) {}
239 typedef boost::shared_ptr<FilenameState> FilenameStatePtr;
240 typedef std::list<FilenameStatePtr> FilenameStateList;
242 FilenameStateList const & get_filenames () { return check_list (filenames); }
243 FilenameStatePtr duplicate_filename_state (FilenameStatePtr state);
244 void remove_filename_state (FilenameStatePtr state);
248 FilenameStateList filenames;
250 bool init_filenames (XMLNodeList nodes);
251 FilenamePtr load_filename (XMLNode & node);
256 std::list<Glib::ustring> errors;
257 std::list<Glib::ustring> warnings;
258 std::list<Glib::ustring> conflicting_filenames;
261 boost::shared_ptr<Warnings> get_warnings ();
264 void check_config (boost::shared_ptr<Warnings> warnings,
265 TimespanStatePtr timespan_state,
266 ChannelConfigStatePtr channel_config_state,
267 FormatStatePtr format_state,
268 FilenameStatePtr filename_state);
272 /* Element state lists should never be empty, this is used to check them */
275 check_list (std::list<T> const & list)
278 throw std::runtime_error ("Programming error: Uninitialized list in ExportProfileManager");
286 } // namespace ARDOUR
288 #endif /* __ardour_export_profile_manager_h__ */