ardour
region_factory.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2000-2007 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_region_factory_h__
21 #define __ardour_region_factory_h__
22 
23 #include <map>
24 #include <set>
25 #include <glibmm/threads.h>
26 
27 #include "pbd/id.h"
28 #include "pbd/property_list.h"
29 #include "pbd/signals.h"
30 
32 #include "ardour/types.h"
33 
34 class XMLNode;
35 class RegionNamingTest;
36 
37 namespace ARDOUR {
38 
39 class Session;
40 class AudioRegion;
41 
43 public:
44  typedef std::map<PBD::ID,boost::shared_ptr<Region> > RegionMap;
45 
46  static boost::shared_ptr<Region> wholefile_region_by_name (const std::string& name);
47  static boost::shared_ptr<Region> region_by_id (const PBD::ID&);
48  static boost::shared_ptr<Region> region_by_name (const std::string& name);
49  static const RegionMap all_regions() { return region_map; }
50  static void clear_map ();
51 
59  static PBD::Signal1<void,boost::shared_ptr<Region> > CheckNewRegion;
60 
62  static boost::shared_ptr<Region> create (boost::shared_ptr<const Region> other, bool announce = false);
63 
66  const PBD::PropertyList&, bool announce = true);
67 
69  static boost::shared_ptr<Region> create (const SourceList &,
70  const PBD::PropertyList&, bool announce = true);
73  const PBD::PropertyList&, bool announce = true);
76  const PBD::PropertyList&, bool announce = true);
78  static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const SourceList& srcs,
79  const PBD::PropertyList&, bool announce = true);
80 
82  static boost::shared_ptr<Region> create (Session&, XMLNode&, bool);
84  static boost::shared_ptr<Region> create (SourceList& srcs, const XMLNode&);
85 
86  static void get_regions_using_source (boost::shared_ptr<Source>, std::set<boost::shared_ptr<Region> >& );
87  static void remove_regions_using_source (boost::shared_ptr<Source>);
88 
89  static void map_remove (boost::weak_ptr<Region>);
90  static void delete_all_regions ();
91  static const RegionMap& regions() { return region_map; }
92  static uint32_t nregions ();
93 
94  static int region_name (std::string &, std::string, bool new_level = false);
95  static std::string new_region_name (std::string);
96  static std::string compound_region_name (const std::string& playlist, uint32_t compound_ops, uint32_t depth, bool whole_source);
97 
98  /* when we make a compound region, for every region involved there
99  * are two "instances" - the original, which is removed from this
100  * playlist, and a copy, which is added to the playlist used as
101  * the source for the compound.
102  *
103  * when we uncombine, we want to put the originals back into this
104  * playlist after we remove the compound. this map lets us
105  * look them up easily. note that if the compound was trimmed or
106  * split, we may have to trim the originals
107  * and they may not be added back if the compound was trimmed
108  * or split sufficiently.
109  */
110 
111  typedef std::map<boost::shared_ptr<Region>, boost::shared_ptr<Region> > CompoundAssociations;
112  static CompoundAssociations& compound_associations() { return _compound_associations; }
113 
114  static void add_compound_association (boost::shared_ptr<Region>, boost::shared_ptr<Region>);
115 
116  /* exposed because there may be cases where regions are created with
117  * announce=false but they still need to be in the map soon after
118  * creation.
119  */
120 
121  static void map_add (boost::shared_ptr<Region>);
122 
123  private:
124  friend class ::RegionNamingTest;
125 
126  static void region_changed (PBD::PropertyChange const &, boost::weak_ptr<Region>);
127 
128  static Glib::Threads::Mutex region_map_lock;
129 
130  static RegionMap region_map;
131 
132  static Glib::Threads::Mutex region_name_maps_mutex;
134  static std::map<std::string, uint32_t> region_name_number_map;
136  static std::map<std::string, PBD::ID> region_name_map;
137  static void add_to_region_name_maps (boost::shared_ptr<Region>);
138  static void rename_in_region_name_maps (boost::shared_ptr<Region>);
139  static void update_region_name_number_map (boost::shared_ptr<Region>);
140  static void remove_from_region_name_map (std::string);
141 
143  static CompoundAssociations _compound_associations;
144 };
145 
146 }
147 
148 #endif /* __ardour_region_factory_h__ */
std::map< PBD::ID, boost::shared_ptr< Region > > RegionMap
static std::map< std::string, PBD::ID > region_name_map
static const RegionMap all_regions()
std::map< boost::shared_ptr< Region >, boost::shared_ptr< Region > > CompoundAssociations
static const RegionMap & regions()
static Glib::Threads::Mutex region_name_maps_mutex
static std::map< std::string, uint32_t > region_name_number_map
Definition: id.h:32
static Glib::Threads::Mutex region_map_lock
static CompoundAssociations _compound_associations
Definition: amp.h:29
static PBD::ScopedConnectionList * region_list_connections
static CompoundAssociations & compound_associations()
int64_t frameoffset_t
Definition: types.h:71
static PBD::Signal1< void, boost::shared_ptr< Region > > CheckNewRegion
#define LIBARDOUR_API
const char * name
Definition: xml++.h:95
std::vector< boost::shared_ptr< Source > > SourceList
Definition: types.h:520
static RegionMap region_map