ardour
file_source.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006-2009 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #ifndef __ardour_filesource_h__
21 #define __ardour_filesource_h__
22 
23 #include <list>
24 #include <string>
25 #include <exception>
26 #include <time.h>
27 #include "ardour/source.h"
28 
29 namespace ARDOUR {
30 
31 class LIBARDOUR_API MissingSource : public std::exception
32 {
33  public:
34  MissingSource (const std::string& p, DataType t) throw ()
35  : path (p), type (t) {}
36  ~MissingSource() throw() {}
37 
38  virtual const char *what() const throw() { return "source file does not exist"; }
39 
40  std::string path;
42 };
43 
45 class LIBARDOUR_API FileSource : virtual public Source {
46 public:
47  virtual ~FileSource ();
48 
49  const std::string& path() const { return _path; }
50 
51  virtual bool safe_file_extension (const std::string& path) const = 0;
52 
53  int move_to_trash (const std::string& trash_dir_name);
54  void mark_take (const std::string& id);
55  void mark_immutable ();
56  void mark_immutable_except_write();
57  void mark_nonremovable ();
58 
59  const std::string& take_id () const { return _take_id; }
60  bool within_session () const { return _within_session; }
61  uint16_t channel() const { return _channel; }
62 
63  int set_state (const XMLNode&, int version);
64 
65  int set_source_name (const std::string& newname, bool destructive);
66 
67  static bool find (Session&, DataType type, const std::string& path,
68  bool must_exist, bool& is_new, uint16_t& chan,
69  std::string& found_path);
70 
71  static bool find_2X (Session&, DataType type, const std::string& path,
72  bool must_exist, bool& is_new, uint16_t& chan,
73  std::string& found_path);
74 
75  void inc_use_count ();
76  bool removable () const;
77  bool is_stub () const;
78 
79  const std::string& origin() const { return _origin; }
80 
81  virtual void set_path (const std::string&);
82 
83  static PBD::Signal2<int,std::string,std::vector<std::string> > AmbiguousFileName;
84 
85  void existence_check ();
86  virtual void prevent_deletion ();
87 
90  int rename (const std::string& name);
91 
92  virtual void close () = 0;
93 
94  protected:
95  FileSource (Session& session, DataType type,
96  const std::string& path,
97  const std::string& origin,
98  Source::Flag flags = Source::Flag(0));
99 
100  FileSource (Session& session, const XMLNode& node, bool must_exist);
101 
102  virtual int init (const std::string& idstr, bool must_exist);
103 
104  virtual int move_dependents_to_trash() { return 0; }
105  void set_within_session_from_path (const std::string&);
106 
107  std::string _path;
108  std::string _take_id;
110  uint16_t _channel;
112  std::string _origin;
113 };
114 
115 } // namespace ARDOUR
116 
117 #endif /* __ardour_filesource_h__ */
118 
uint16_t channel() const
Definition: file_source.h:61
static PBD::Signal2< int, std::string, std::vector< std::string > > AmbiguousFileName
Definition: file_source.h:83
virtual const char * what() const
Definition: file_source.h:38
const std::string & take_id() const
Definition: file_source.h:59
#define origin
bool within_session() const
Definition: file_source.h:60
Definition: amp.h:29
std::string _take_id
Definition: file_source.h:108
std::string _path
Definition: file_source.h:107
const std::string & origin() const
Definition: file_source.h:79
#define LIBARDOUR_API
virtual int move_dependents_to_trash()
Definition: file_source.h:104
MissingSource(const std::string &p, DataType t)
Definition: file_source.h:34
const std::string & path() const
Definition: file_source.h:49
const char * name
std::string _origin
Definition: file_source.h:112
Definition: xml++.h:95
LIBARDOUR_API bool init(bool with_vst, bool try_optimization, const char *localedir)
Definition: globals.cc:376