2 Copyright (C) 2000-2007 Paul Davis
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.
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.
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.
20 #ifndef __ardour_region_factory_h__
21 #define __ardour_region_factory_h__
25 #include <glibmm/thread.h>
28 #include "pbd/signals.h"
30 #include "ardour/types.h"
41 typedef std::map<PBD::ID,boost::shared_ptr<Region> > RegionMap;
43 static boost::shared_ptr<Region> wholefile_region_by_name (const std::string& name);
44 static boost::shared_ptr<Region> region_by_id (const PBD::ID&);
45 static boost::shared_ptr<Region> region_by_name (const std::string& name);
46 static const RegionMap all_regions() { return region_map; }
47 static void clear_map ();
49 /** This is emitted only when a new id is assigned. Therefore,
50 in a pure Region copy, it will not be emitted.
52 It must be emitted using a derived instance of Region, not Region
53 itself, to permit dynamic_cast<> to be used to
54 infer the type of Region.
56 static PBD::Signal1<void,boost::shared_ptr<Region> > CheckNewRegion;
58 /** create a "pure copy" of Region @param other */
59 static boost::shared_ptr<Region> create (boost::shared_ptr<const Region> other, bool announce = false);
61 /** create a region from a single Source */
62 static boost::shared_ptr<Region> create (boost::shared_ptr<Source>,
63 const PBD::PropertyList&, bool announce = true);
64 /** create a region from a multiple sources */
65 static boost::shared_ptr<Region> create (const SourceList &,
66 const PBD::PropertyList&, bool announce = true);
67 /** create a copy of @other starting at zero within @param other's sources */
68 static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other,
69 const PBD::PropertyList&, bool announce = true);
70 /** create a copy of @param other starting at @param offset within @param other */
71 static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, frameoffset_t offset,
72 const PBD::PropertyList&, bool announce = true);
73 /** create a "copy" of @param other but using a different set of sources @param srcs */
74 static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const SourceList& srcs,
75 const PBD::PropertyList&, bool announce = true);
77 /** create a region with no sources, using XML state */
78 static boost::shared_ptr<Region> create (Session&, XMLNode&, bool);
79 /** create a region with specified sources @param srcs and XML state */
80 static boost::shared_ptr<Region> create (SourceList& srcs, const XMLNode&);
82 static void get_regions_using_source (boost::shared_ptr<Source>, std::set<boost::shared_ptr<Region> >& );
83 static void remove_regions_using_source (boost::shared_ptr<Source>);
85 static void map_remove (boost::shared_ptr<Region>);
86 static void map_remove_with_equivalents (boost::shared_ptr<Region>);
87 static void delete_all_regions ();
88 static const RegionMap& regions() { return region_map; }
89 static uint32_t nregions ();
91 static int region_name (std::string &, std::string, bool new_level = false);
92 static std::string new_region_name (std::string);
96 static void region_changed (PBD::PropertyChange const &, boost::weak_ptr<Region>);
98 static Glib::StaticMutex region_map_lock;
100 static RegionMap region_map;
101 static void map_add (boost::shared_ptr<Region>);
103 static Glib::StaticMutex region_name_map_lock;
105 static std::map<std::string, uint32_t> region_name_map;
106 static void update_region_name_map (boost::shared_ptr<Region>);
108 static PBD::ScopedConnectionList region_list_connections;
113 #endif /* __ardour_region_factory_h__ */