From f2b007195cd75b195e38a4cd7757debac73e7792 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 17 Sep 2008 12:58:33 +0000 Subject: new files from sakari, missed last time git-svn-id: svn://localhost/ardour2/branches/3.0@3740 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/export_profile_manager.h | 316 ++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 libs/ardour/ardour/export_profile_manager.h (limited to 'libs/ardour/ardour/export_profile_manager.h') diff --git a/libs/ardour/ardour/export_profile_manager.h b/libs/ardour/ardour/export_profile_manager.h new file mode 100644 index 0000000000..1a855d6868 --- /dev/null +++ b/libs/ardour/ardour/export_profile_manager.h @@ -0,0 +1,316 @@ +/* + Copyright (C) 2008 Paul Davis + Author: Sakari Bergen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_export_profile_manager_h__ +#define __ardour_export_profile_manager_h__ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +using std::string; +using std::list; +using std::set; + +namespace ARDOUR +{ + +class ExportHandler; +class ExportTimespan; +class ExportChannelConfiguration; +class ExportFormatSpecification; +class ExportFilename; +class Location; +class Session; + +/// Manages (de)serialization of export profiles and related classes +class ExportProfileManager +{ + public: + class Preset { + public: + Preset (string filename, Session & s); + ~Preset (); + + uint32_t id () const { return _id; } + string name () const { return _name; } + + void set_name (string name); + void set_id (uint32_t id); + + // Note: The set_..._state functions take ownership of the XMLNode + void set_global_state (XMLNode & state); + void set_local_state (XMLNode & state); + + XMLNode const * get_global_state () const { return global.root(); } + XMLNode const * get_local_state () const { return local; } + + void save () const; + void remove_local () const; + + private: + + XMLNode * get_instant_xml () const; + void save_instant_xml () const; + void remove_instant_xml () const; + + uint32_t _id; + string _name; + + Session & session; + XMLTree global; + XMLNode * local; + + }; + + typedef boost::shared_ptr PresetPtr; + typedef std::list PresetList; + + public: + + ExportProfileManager (Session & s); + ~ExportProfileManager (); + + void load_profile (); + void prepare_for_export (); + + PresetList const & get_presets () { return preset_list; } + void load_preset (PresetPtr preset); + PresetPtr save_preset (string const & name); + void remove_preset (); + + private: + typedef boost::shared_ptr HandlerPtr; + + typedef std::pair FilePair; + typedef std::map FileMap; + + HandlerPtr handler; + Session & session; + + void load_presets (); + uint32_t load_preset_from_disk (PBD::sys::path const & path); // Returns preset id + + void set_state (XMLNode const & root); + void set_global_state (XMLNode const & root); + void set_local_state (XMLNode const & root); + + void serialize_profile (XMLNode & root); + void serialize_global_profile (XMLNode & root); + void serialize_local_profile (XMLNode & root); + + PresetList preset_list; + PresetPtr current_preset; + uint32_t preset_id_counter; + FileMap preset_file_map; + + std::vector find_file (std::string const & pattern); + + PBD::sys::path export_config_dir; + PBD::SearchPath search_path; + +/* Timespans */ + public: + + typedef boost::shared_ptr TimespanPtr; + typedef std::list TimespanList; + typedef boost::shared_ptr TimespanListPtr; + typedef std::list LocationList; + + enum TimeFormat { + SMPTE, + BBT, + MinSec, + Frames, + Off + }; + + struct TimespanState { + TimespanListPtr timespans; + TimeFormat time_format; + + boost::shared_ptr session_range; + boost::shared_ptr selection_range; + boost::shared_ptr ranges; + + TimespanState (boost::shared_ptr session_range, + boost::shared_ptr selection_range, + boost::shared_ptr ranges) : + timespans (new TimespanList ()), + time_format (SMPTE), + + session_range (session_range), + selection_range (selection_range), + ranges (ranges) + {} + }; + + typedef boost::shared_ptr TimespanStatePtr; + typedef std::list TimespanStateList; + + void set_selection_range (nframes_t start = 0, nframes_t end = 0); + TimespanStateList const & get_timespans () { return timespans; } + + private: + + TimespanStateList timespans; + + void init_timespans (XMLNodeList nodes); + + TimespanStatePtr deserialize_timespan (XMLNode & root); + XMLNode & serialize_timespan (TimespanStatePtr state); + + /* Locations */ + + void update_ranges (); + + boost::shared_ptr session_range; + boost::shared_ptr selection_range; + boost::shared_ptr ranges; + +/* Channel Configs */ + public: + + typedef boost::shared_ptr ChannelConfigPtr; + + struct ChannelConfigState { + ChannelConfigPtr config; + + ChannelConfigState (ChannelConfigPtr ptr) : config (ptr) {} + }; + typedef boost::shared_ptr ChannelConfigStatePtr; + typedef std::list ChannelConfigStateList; + + ChannelConfigStateList const & get_channel_configs () { return channel_configs; } + + private: + + ChannelConfigStateList channel_configs; + + void init_channel_configs (XMLNodeList nodes); + + ChannelConfigStatePtr deserialize_channel_config (XMLNode & root); + XMLNode & serialize_channel_config (ChannelConfigStatePtr state); + +/* Formats */ + public: + + typedef boost::shared_ptr FormatPtr; + typedef std::list FormatList; + + struct FormatState { + boost::shared_ptr list; + FormatPtr format; + + FormatState (boost::shared_ptr list, FormatPtr format) : + list (list), format (format) {} + }; + typedef boost::shared_ptr FormatStatePtr; + typedef std::list FormatStateList; + + FormatStateList const & get_formats () { return formats; } + FormatStatePtr duplicate_format_state (FormatStatePtr state); + void remove_format_state (FormatStatePtr state); + + PBD::sys::path save_format_to_disk (FormatPtr format); + void remove_format_profile (FormatPtr format); + FormatPtr get_new_format (FormatPtr original); + + sigc::signal FormatListChanged; + + private: + + FormatStateList formats; + + void init_formats (XMLNodeList nodes); + FormatStatePtr deserialize_format (XMLNode & root); + XMLNode & serialize_format (FormatStatePtr state); + + void load_formats (); + + FormatPtr load_format (XMLNode & node); + void load_format_from_disk (PBD::sys::path const & path); + + boost::shared_ptr format_list; + FileMap format_file_map; + +/* Filenames */ + public: + + typedef boost::shared_ptr FilenamePtr; + + struct FilenameState { + FilenamePtr filename; + + FilenameState (FilenamePtr ptr) : filename (ptr) {} + }; + typedef boost::shared_ptr FilenameStatePtr; + typedef std::list FilenameStateList; + + FilenameStateList const & get_filenames () { return filenames; } + FilenameStatePtr duplicate_filename_state (FilenameStatePtr state); + void remove_filename_state (FilenameStatePtr state); + + private: + + FilenameStateList filenames; + + void init_filenames (XMLNodeList nodes); + + FilenameStatePtr deserialize_filename (XMLNode & root); + XMLNode & serialize_filename (FilenameStatePtr state); + + FilenamePtr load_filename (XMLNode & node); + +/* Warnings */ + public: + struct Warnings { + std::list errors; + std::list warnings; + std::list conflicting_filenames; + }; + + boost::shared_ptr get_warnings (); + + private: + void check_config (boost::shared_ptr warnings, + TimespanStatePtr timespan_state, + ChannelConfigStatePtr channel_config_state, + FormatStatePtr format_state, + FilenameStatePtr filename_state); +}; + + +} // namespace ARDOUR + +#endif /* __ardour_export_profile_manager_h__ */ -- cgit v1.2.3