f5f19d5b5b33f97f39c56d3d7645f2bab759f601
[ardour.git] / libs / ardour / playlist_factory.cc
1 /*
2     Copyright (C) 2000-2006 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     $Id$
19 */
20
21 #include <pbd/error.h>
22
23 #include <ardour/playlist.h>
24 #include <ardour/audioplaylist.h>
25 #include <ardour/playlist_factory.h>
26
27 #include "i18n.h"
28
29 using namespace ARDOUR;
30 using namespace PBD;
31
32 sigc::signal<void,boost::shared_ptr<Playlist> > PlaylistFactory::PlaylistCreated;
33
34 boost::shared_ptr<Playlist> 
35 PlaylistFactory::create (Session& s, const XMLNode& node, bool hidden) 
36 {
37         boost::shared_ptr<Playlist> pl;
38
39         pl = boost::shared_ptr<Playlist> (new AudioPlaylist (s, node, hidden));
40
41         pl->set_region_ownership ();
42
43         if (!hidden) {
44                 PlaylistCreated (pl);
45         }
46         return pl;
47 }
48
49 boost::shared_ptr<Playlist> 
50 PlaylistFactory::create (Session& s, string name, bool hidden) 
51 {
52         boost::shared_ptr<Playlist> pl;
53
54         pl = boost::shared_ptr<Playlist> (new AudioPlaylist (s, name, hidden));
55
56         if (!hidden) {
57                 PlaylistCreated (pl);
58         }
59
60         return pl;
61 }
62
63 boost::shared_ptr<Playlist> 
64 PlaylistFactory::create (boost::shared_ptr<const Playlist> old, string name, bool hidden) 
65 {
66         boost::shared_ptr<Playlist> pl;
67         boost::shared_ptr<const AudioPlaylist> apl;
68
69         if ((apl = boost::dynamic_pointer_cast<const AudioPlaylist> (old)) != 0) {
70                 pl = boost::shared_ptr<Playlist> (new AudioPlaylist (apl, name, hidden));
71                 pl->set_region_ownership ();
72         }
73
74         if (!hidden) {
75                 PlaylistCreated (pl);
76         }
77
78         return pl;
79 }
80
81 boost::shared_ptr<Playlist> 
82 PlaylistFactory::create (boost::shared_ptr<const Playlist> old, nframes_t start, nframes_t cnt, string name, bool hidden) 
83 {
84         boost::shared_ptr<Playlist> pl;
85         boost::shared_ptr<const AudioPlaylist> apl;
86         
87         if ((apl = boost::dynamic_pointer_cast<const AudioPlaylist> (old)) != 0) {
88                 pl = boost::shared_ptr<Playlist> (new AudioPlaylist (apl, start, cnt, name, hidden));
89                 pl->set_region_ownership ();
90         }
91
92
93         /* this factory method does NOT notify others */
94
95         return pl;
96 }