summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/session_playlists.h
blob: 273b12d040cd549329efd481ca7ba9b2d0f529c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
    Copyright (C) 2009 Paul Davis

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef __ardour_session_playlists_h__
#define __ardour_session_playlists_h__

#include <set>
#include <vector>
#include <string>
#include <glibmm/threads.h>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>

#include "pbd/signals.h"

class XMLNode;

namespace PBD {
	class ID;
}

namespace ARDOUR {

class Playlist;
class Region;
class Source;
class Session;
class Crossfade;
class Track;

class LIBARDOUR_API SessionPlaylists : public PBD::ScopedConnectionList
{
public:
	~SessionPlaylists ();

	boost::shared_ptr<Playlist> by_name (std::string name);
	boost::shared_ptr<Playlist> by_id (const PBD::ID&);
	uint32_t source_use_count (boost::shared_ptr<const Source> src) const;
	uint32_t region_use_count (boost::shared_ptr<Region> region) const;
	template<class T> void foreach (T *obj, void (T::*func)(boost::shared_ptr<Playlist>));
	void foreach (boost::function<void(boost::shared_ptr<const Playlist>)> functor, bool incl_unused = true);
	void get (std::vector<boost::shared_ptr<Playlist> >&) const;
	void unassigned (std::list<boost::shared_ptr<Playlist> > & list);
	void destroy_region (boost::shared_ptr<Region>);
	boost::shared_ptr<Crossfade> find_crossfade (const PBD::ID &);
	void sync_all_regions_with_regions ();
	std::vector<boost::shared_ptr<Playlist> > playlists_for_track (boost::shared_ptr<Track>) const;
	uint32_t n_playlists() const;

private:
	friend class Session;

	bool add (boost::shared_ptr<Playlist>);
	void remove (boost::shared_ptr<Playlist>);
	void remove_weak (boost::weak_ptr<Playlist>);
	void track (bool, boost::weak_ptr<Playlist>);

	void find_equivalent_playlist_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >& result);
	void update_after_tempo_map_change ();
	void add_state (XMLNode *, bool);
	bool maybe_delete_unused (boost::function<int(boost::shared_ptr<Playlist>)>);
	int load (Session &, const XMLNode&);
	int load_unused (Session &, const XMLNode&);
	boost::shared_ptr<Playlist> XMLPlaylistFactory (Session &, const XMLNode&);

	mutable Glib::Threads::Mutex lock;
	typedef std::set<boost::shared_ptr<Playlist> > List;
	List playlists;
	List unused_playlists;
};

}

#endif