summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/file_source.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-02-17 02:11:49 +0000
committerDavid Robillard <d@drobilla.net>2009-02-17 02:11:49 +0000
commit022818b4a796f52c0a91eea42e65aec0bc7bed43 (patch)
treef82bde33d44c7b3e16af7e837536665e17fe0189 /libs/ardour/ardour/file_source.h
parent4565b73a3993b0cb5ccb9170e276180f2b5c1372 (diff)
Fix the horrible mess that was anything related to sources and paths.
Most significant changes: - Factor out FileSource from AudioFileSource, use for SMFSource too - Explicitly pass embedded rather than mysterious name mangling or whatever - Destroy a ton of duplicated or very-nearly-duplicated code - Clean up and document all that weird source stuff in session.cc git-svn-id: svn://localhost/ardour2/branches/3.0@4609 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/file_source.h')
-rw-r--r--libs/ardour/ardour/file_source.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/libs/ardour/ardour/file_source.h b/libs/ardour/ardour/file_source.h
new file mode 100644
index 0000000000..0d6cae9b18
--- /dev/null
+++ b/libs/ardour/ardour/file_source.h
@@ -0,0 +1,83 @@
+/*
+ Copyright (C) 2006-2009 Paul Davis
+
+ 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_filesource_h__
+#define __ardour_filesource_h__
+
+#include <exception>
+#include <time.h>
+#include <ardour/source.h>
+
+namespace ARDOUR {
+
+class MissingSource : public std::exception {
+public:
+ virtual const char *what() const throw() { return "source file does not exist"; }
+};
+
+/** A source associated with a file on disk somewhere */
+class FileSource : virtual public Source {
+public:
+ const Glib::ustring& path() const { return _path; }
+
+ virtual bool safe_file_extension (const Glib::ustring& path) const = 0;
+
+ int move_to_trash (const Glib::ustring& trash_dir_name);
+ void mark_take (const Glib::ustring& id);
+ void mark_immutable ();
+
+ const Glib::ustring& take_id () const { return _take_id; }
+ bool is_embedded () const { return _is_embedded; }
+ uint16_t channel() const { return _channel; }
+
+ int set_state (const XMLNode&);
+
+ int set_source_name (const Glib::ustring& newname, bool destructive);
+
+ static void set_search_path (DataType type, const Glib::ustring& path);
+
+protected:
+ FileSource (Session& session, DataType type,
+ const Glib::ustring& path, bool embedded,
+ Source::Flag flags = Source::Flag(0));
+
+ FileSource (Session& session, const XMLNode& node, bool must_exist);
+
+ virtual int init (const Glib::ustring& idstr, bool must_exist);
+
+ virtual int move_dependents_to_trash() { return 0; }
+
+ bool find (DataType type, const Glib::ustring& path,
+ bool must_exist, bool& is_new, uint16_t& chan);
+
+ bool removable () const;
+
+ Glib::ustring _path;
+ Glib::ustring _take_id;
+ bool _file_is_new;
+ uint16_t _channel;
+ bool _is_embedded;
+
+ static map<DataType, Glib::ustring> search_paths;
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_filesource_h__ */
+