new file
[ardour.git] / libs / ardour / ardour / region_factory.h
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
25 #include "pbd/id.h"
26
27 #include "ardour/types.h"
28 #include "ardour/region.h"
29
30 class XMLNode;
31
32 namespace ARDOUR {
33
34 class Session;
35 class AudioRegion;
36
37 class RegionFactory {
38
39   public:
40
41         static boost::shared_ptr<Region> region_by_id (const PBD::ID&);
42         static void clear_map ();
43
44         /** This is emitted only when a new id is assigned. Therefore,
45            in a pure Region copy, it will not be emitted.
46
47            It must be emitted by derived classes, not Region
48            itself, to permit dynamic_cast<> to be used to
49            infer the type of Region.
50         */
51         static PBD::Signal1<void,boost::shared_ptr<Region> >  CheckNewRegion;
52
53         static boost::shared_ptr<Region> create (boost::shared_ptr<const Region>);
54
55         /* note: both of the first two should use const shared_ptr as well, but
56            gcc 4.1 doesn't seem to be able to disambiguate them if they do.
57         */
58
59         static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, nframes_t start,
60                         nframes_t length, const std::string& name,
61                         layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
62         static boost::shared_ptr<Region> create (boost::shared_ptr<AudioRegion>, nframes_t start,
63                         nframes_t length, const std::string& name,
64                         layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
65         static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, const SourceList&, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
66         static boost::shared_ptr<Region> create (boost::shared_ptr<Source>, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
67         static boost::shared_ptr<Region> create (const SourceList &, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
68         static boost::shared_ptr<Region> create (Session&, XMLNode&, bool);
69         static boost::shared_ptr<Region> create (SourceList &, const XMLNode&);
70
71   private:
72         static std::map<PBD::ID,boost::weak_ptr<Region> > region_map;
73         static void map_add (boost::shared_ptr<Region>);
74 };
75
76 }
77
78 #endif /* __ardour_region_factory_h__  */