Merged with trunk R846
[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/session.h>
24
25 #include <ardour/playlist.h>
26 #include <ardour/audioplaylist.h>
27
28 #include <ardour/region_factory.h>
29 #include <ardour/region.h>
30 #include <ardour/audioregion.h>
31
32 #include "i18n.h"
33
34 using namespace ARDOUR;
35 using namespace PBD;
36
37 Region*
38 ARDOUR::createRegion (const Region& region, jack_nframes_t start, 
39                       jack_nframes_t length, std::string name, 
40                       layer_t layer, Region::Flag flags)
41 {
42         const AudioRegion* ar;
43         
44         if ((ar = dynamic_cast<const AudioRegion*>(&region)) != 0) {
45                 AudioRegion* ret;
46                 ret = new AudioRegion (*ar, start, length, name, layer, flags);
47                 return ret;
48         } else {
49                 fatal << _("programming error: Playlist::createRegion called with unknown Region type")
50                       << endmsg;
51                 /*NOTREACHED*/
52                 return 0;
53         }
54 }
55
56 Region*
57 ARDOUR::createRegion (const Region& region)
58 {
59         const AudioRegion* ar;
60         
61         if ((ar = dynamic_cast<const AudioRegion*>(&region)) != 0) {
62                 return new AudioRegion (*ar);
63         } else {
64                 fatal << _("programming error: Playlist::createRegion called with unknown Region type")
65                       << endmsg;
66                 /*NOTREACHED*/
67                 return 0;
68         }
69 }
70
71 Region*
72 ARDOUR::createRegion (Session& session, XMLNode& node, bool yn)
73 {
74         return session.XMLRegionFactory (node, yn);
75 }
76         
77 Playlist*
78 Playlist::copyPlaylist (const Playlist& playlist, jack_nframes_t start, jack_nframes_t length,
79                         string name, bool result_is_hidden)
80 {
81         const AudioPlaylist* apl;
82
83         if ((apl = dynamic_cast<const AudioPlaylist*> (&playlist)) != 0) {
84                 return new AudioPlaylist (*apl, start, length, name, result_is_hidden);
85         } else {
86                 fatal << _("programming error: Playlist::copyPlaylist called with unknown Playlist type")
87                       << endmsg;
88                 /*NOTREACHED*/
89                 return 0;
90         }
91 }