Ardour  9.0-pre0-439-ga53b99b307
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 #pragma once
23 
24 #include <list>
25 #include <string>
26 #include <exception>
27 #include <time.h>
28 #include "ardour/source.h"
29 
30 namespace ARDOUR {
31 
32 class LIBARDOUR_API MissingSource : public std::exception
33 {
34  public:
35  MissingSource (const std::string& p, DataType t) throw ()
36  : path (p), type (t) {}
37  ~MissingSource() throw() {}
38 
39  virtual const char *what() const throw() { return "source file does not exist"; }
40 
41  std::string path;
43 };
44 
46 class LIBARDOUR_API FileSource : virtual public Source {
47 public:
48  virtual ~FileSource ();
49 
50  const std::string& path() const { return _path; }
51 
52  virtual bool safe_file_extension (const std::string& path) const = 0;
53 
54  int move_to_trash (const std::string& trash_dir_name);
55  void mark_take (const std::string& id);
56  void mark_immutable ();
59 
60  bool within_session () const { return _within_session; }
61  uint16_t channel() const { return _channel; }
62  float gain() const { return _gain; }
63 
64  virtual void set_gain (float g, bool temporarily = false) { _gain = g; }
65  virtual void set_channel (uint16_t c) { _channel = c; }
66 
67  int set_state (const XMLNode&, int version);
68 
69  int set_source_name (const std::string& newname);
70 
71  static bool find (Session&, DataType type, const std::string& path,
72  bool must_exist, bool& is_new, uint16_t& chan,
73  std::string& found_path);
74 
75  static bool find_2X (Session&, DataType type, const std::string& path,
76  bool must_exist, bool& is_new, uint16_t& chan,
77  std::string& found_path);
78 
79  bool removable () const;
80  bool is_stub () const;
81 
82  const std::string& origin() const { return _origin; }
83  void set_origin (std::string const& o) { _origin = o; }
84 
85  virtual void set_path (const std::string&);
86  void replace_file (const std::string&);
87 
88  static PBD::Signal<int(std::string,std::vector<std::string> )> AmbiguousFileName;
89 
90  void existence_check ();
91  virtual void prevent_deletion ();
92 
94  int rename (const std::string& name);
95 
96  virtual void close () = 0;
97 
98  protected:
100  const std::string& path,
101  const std::string& origin,
102  Source::Flag flags = Source::Flag(0));
103 
104  FileSource (Session& session, const XMLNode& node, bool must_exist);
105 
106  virtual int init (const std::string& idstr, bool must_exist);
107 
108  virtual int move_dependents_to_trash() { return 0; }
109  void set_within_session_from_path (const std::string&);
110 
111  std::string _path;
113  uint16_t _channel;
115  std::string _origin;
116  float _gain;
117 };
118 
119 } // namespace ARDOUR
120 
121 
void mark_take(const std::string &id)
uint16_t channel() const
Definition: file_source.h:61
virtual void set_channel(uint16_t c)
Definition: file_source.h:65
void set_origin(std::string const &o)
Definition: file_source.h:83
static PBD::Signal< int(std::string, std::vector< std::string >)> AmbiguousFileName
Definition: file_source.h:88
int set_state(const XMLNode &, int version)
virtual ~FileSource()
virtual void prevent_deletion()
bool within_session() const
Definition: file_source.h:60
std::string _origin
Definition: file_source.h:115
const std::string & origin() const
Definition: file_source.h:82
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:62
virtual void set_gain(float g, bool temporarily=false)
Definition: file_source.h:64
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)
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:111
bool removable() const
void set_within_session_from_path(const std::string &)
virtual int move_dependents_to_trash()
Definition: file_source.h:108
const std::string & path() const
Definition: file_source.h:50
MissingSource(const std::string &p, DataType t)
Definition: file_source.h:35
virtual const char * what() const
Definition: file_source.h:39
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
void session(lua_State *L)