Ardour  8.12
audio_region_importer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Sakari Bergen <sakari.bergen@beatwaves.net>
3  * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __ardour_audio_region_importer_h__
21 #define __ardour_audio_region_importer_h__
22 
23 #include <list>
24 #include <map>
25 #include <memory>
26 #include <utility>
27 
28 
29 #include "pbd/xml++.h"
30 #include "pbd/id.h"
33 #include "ardour/import_status.h"
34 
35 namespace ARDOUR {
36 
37 class Region;
38 class Session;
39 class Source;
40 
42 {
43  public:
44  // Inerface implementation
46  std::string get_info () const;
47 
48  void create_regions_from_children (XMLNode const & node, ElementList & list);
49 
50  // Source management
51  bool check_source (std::string const & filename) const;
52  void add_source (std::string const & filename, std::shared_ptr<Source> const & source);
53  std::shared_ptr<Source> const & get_source (std::string const & filename) const;
54 
55  // Id management
56  void register_id (PBD::ID & old_id, PBD::ID & new_id);
57  PBD::ID const & get_new_id (PBD::ID & old_id) const;
58 
59  private:
60  // Source management
61  typedef std::map<std::string, std::shared_ptr<Source> > SourceMap;
62  typedef std::pair<std::string, std::shared_ptr<Source> > SourcePair;
64 
65  // Id management
66  typedef std::map<PBD::ID, PBD::ID> IdMap;
67  typedef std::pair<PBD::ID, PBD::ID> IdPair;
69 };
70 
72 {
73  public:
74  AudioRegionImporter (XMLTree const & source, Session & session, AudioRegionImportHandler & handler, XMLNode const & node);
76 
77  // Interface implementation
78  std::string get_info () const;
79  ImportStatus * get_import_status () { return &status; }
80 
81  // other stuff
83  XMLNode const & get_xml ();
84 
85  protected:
86  bool _prepare_move ();
87  void _cancel_move ();
88  void _move ();
89 
90  private:
91 
96  std::list<std::string> filenames;
98 
101  std::string get_sound_dir (XMLTree const & tree);
102 
103  void prepare_region ();
105  std::vector<std::shared_ptr<Region> > region;
108 };
109 
110 } // namespace ARDOUR
111 
112 #endif
std::pair< PBD::ID, PBD::ID > IdPair
std::string get_info() const
std::map< std::string, std::shared_ptr< Source > > SourceMap
void add_source(std::string const &filename, std::shared_ptr< Source > const &source)
void create_regions_from_children(XMLNode const &node, ElementList &list)
std::pair< std::string, std::shared_ptr< Source > > SourcePair
PBD::ID const & get_new_id(PBD::ID &old_id) const
std::map< PBD::ID, PBD::ID > IdMap
std::shared_ptr< Source > const & get_source(std::string const &filename) const
bool check_source(std::string const &filename) const
void register_id(PBD::ID &old_id, PBD::ID &new_id)
AudioRegionImportHandler(XMLTree const &source, Session &session)
std::list< std::string > filenames
std::string get_sound_dir(XMLTree const &tree)
std::vector< std::shared_ptr< Region > > region
std::string get_info() const
void _cancel_move()
Cancel move.
XMLNode const & get_xml()
AudioRegionImportHandler & handler
AudioRegionImporter(XMLTree const &source, Session &session, AudioRegionImportHandler &handler, XMLNode const &node)
Virtual interface class for element import handlers.
std::list< ElementPtr > ElementList
Virtual interface class for element importers.
Definition: id.h:35
Definition: xml++.h:114
Definition: xml++.h:74
#define LIBARDOUR_API
void session(lua_State *L)