Ardour  8.12
file_source.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
4  * Copyright (C) 2009-2015 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef __ardour_filesource_h__
23 #define __ardour_filesource_h__
24 
25 #include <list>
26 #include <string>
27 #include <exception>
28 #include <time.h>
29 #include "ardour/source.h"
30 
31 namespace ARDOUR {
32 
33 class LIBARDOUR_API MissingSource : public std::exception
34 {
35  public:
36  MissingSource (const std::string& p, DataType t) throw ()
37  : path (p), type (t) {}
38  ~MissingSource() throw() {}
39 
40  virtual const char *what() const throw() { return "source file does not exist"; }
41 
42  std::string path;
44 };
45 
47 class LIBARDOUR_API FileSource : virtual public Source {
48 public:
49  virtual ~FileSource ();
50 
51  const std::string& path() const { return _path; }
52 
53  virtual bool safe_file_extension (const std::string& path) const = 0;
54 
55  int move_to_trash (const std::string& trash_dir_name);
56  void mark_take (const std::string& id);
57  void mark_immutable ();
60 
61  bool within_session () const { return _within_session; }
62  uint16_t channel() const { return _channel; }
63  float gain() const { return _gain; }
64 
65  virtual void set_gain (float g, bool temporarily = false) { _gain = g; }
66  virtual void set_channel (uint16_t c) { _channel = c; }
67 
68  int set_state (const XMLNode&, int version);
69 
70  int set_source_name (const std::string& newname);
71 
72  static bool find (Session&, DataType type, const std::string& path,
73  bool must_exist, bool& is_new, uint16_t& chan,
74  std::string& found_path);
75 
76  static bool find_2X (Session&, DataType type, const std::string& path,
77  bool must_exist, bool& is_new, uint16_t& chan,
78  std::string& found_path);
79 
80  bool removable () const;
81  bool is_stub () const;
82 
83  const std::string& origin() const { return _origin; }
84  void set_origin (std::string const& o) { _origin = o; }
85 
86  virtual void set_path (const std::string&);
87  void replace_file (const std::string&);
88 
89  static PBD::Signal2<int,std::string,std::vector<std::string> > AmbiguousFileName;
90 
91  void existence_check ();
92  virtual void prevent_deletion ();
93 
95  int rename (const std::string& name);
96 
97  virtual void close () = 0;
98 
99  protected:
101  const std::string& path,
102  const std::string& origin,
103  Source::Flag flags = Source::Flag(0));
104 
105  FileSource (Session& session, const XMLNode& node, bool must_exist);
106 
107  virtual int init (const std::string& idstr, bool must_exist);
108 
109  virtual int move_dependents_to_trash() { return 0; }
110  void set_within_session_from_path (const std::string&);
111 
112  std::string _path;
114  uint16_t _channel;
116  std::string _origin;
117  float _gain;
118 };
119 
120 } // namespace ARDOUR
121 
122 #endif /* __ardour_filesource_h__ */
123 
void mark_take(const std::string &id)
uint16_t channel() const
Definition: file_source.h:62
virtual void set_channel(uint16_t c)
Definition: file_source.h:66
void set_origin(std::string const &o)
Definition: file_source.h:84
int set_state(const XMLNode &, int version)
virtual ~FileSource()
virtual void prevent_deletion()
bool within_session() const
Definition: file_source.h:61
std::string _origin
Definition: file_source.h:116
const std::string & origin() const
Definition: file_source.h:83
virtual void set_path(const std::string &)
void mark_immutable_except_write()
static bool find_2X(Session &, DataType type, const std::string &path, bool must_exist, bool &is_new, uint16_t &chan, std::string &found_path)
virtual void close()=0
virtual bool safe_file_extension(const std::string &path) const =0
float gain() const
Definition: file_source.h:63
virtual void set_gain(float g, bool temporarily=false)
Definition: file_source.h:65
FileSource(Session &session, const XMLNode &node, bool must_exist)
int set_source_name(const std::string &newname)
bool is_stub() const
int move_to_trash(const std::string &trash_dir_name)
void replace_file(const std::string &)
static bool find(Session &, DataType type, const std::string &path, bool must_exist, bool &is_new, uint16_t &chan, std::string &found_path)
static PBD::Signal2< int, std::string, std::vector< std::string > > AmbiguousFileName
Definition: file_source.h:89
int rename(const std::string &name)
FileSource(Session &session, DataType type, const std::string &path, const std::string &origin, Source::Flag flags=Source::Flag(0))
virtual int init(const std::string &idstr, bool must_exist)
std::string _path
Definition: file_source.h:112
bool removable() const
void set_within_session_from_path(const std::string &)
virtual int move_dependents_to_trash()
Definition: file_source.h:109
const std::string & path() const
Definition: file_source.h:51
MissingSource(const std::string &p, DataType t)
Definition: file_source.h:36
virtual const char * what() const
Definition: file_source.h:40
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
void session(lua_State *L)