Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
21 
22 #include <list>
23 #include <map>
24 #include <memory>
25 #include <utility>
26 
27 
28 #include "pbd/xml++.h"
29 #include "pbd/id.h"
32 #include "ardour/import_status.h"
33 
34 namespace ARDOUR {
35 
36 class Region;
37 class Session;
38 class Source;
39 
41 {
42  public:
43  // Inerface implementation
45  std::string get_info () const;
46 
47  void create_regions_from_children (XMLNode const & node, ElementList & list);
48 
49  // Source management
50  bool check_source (std::string const & filename) const;
51  void add_source (std::string const & filename, std::shared_ptr<Source> const & source);
52  std::shared_ptr<Source> const & get_source (std::string const & filename) const;
53 
54  // Id management
55  void register_id (PBD::ID & old_id, PBD::ID & new_id);
56  PBD::ID const & get_new_id (PBD::ID & old_id) const;
57 
58  private:
59  // Source management
60  typedef std::map<std::string, std::shared_ptr<Source> > SourceMap;
61  typedef std::pair<std::string, std::shared_ptr<Source> > SourcePair;
63 
64  // Id management
65  typedef std::map<PBD::ID, PBD::ID> IdMap;
66  typedef std::pair<PBD::ID, PBD::ID> IdPair;
68 };
69 
71 {
72  public:
73  AudioRegionImporter (XMLTree const & source, Session & session, AudioRegionImportHandler & handler, XMLNode const & node);
75 
76  // Interface implementation
77  std::string get_info () const;
78  ImportStatus * get_import_status () { return &status; }
79 
80  // other stuff
82  XMLNode const & get_xml ();
83 
84  protected:
85  bool _prepare_move ();
86  void _cancel_move ();
87  void _move ();
88 
89  private:
90 
95  std::list<std::string> filenames;
97 
100  std::string get_sound_dir (XMLTree const & tree);
101 
102  void prepare_region ();
104  std::vector<std::shared_ptr<Region> > region;
107 };
108 
109 } // namespace ARDOUR
110 
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:34
Definition: xml++.h:114
Definition: xml++.h:74
#define LIBARDOUR_API
void session(lua_State *L)