c61e95b52ab2b8919a58eef8af0265ca9905266b
[ardour.git] / libs / ardour / ardour / export_timespan.h
1 /*
2  * Copyright (C) 2008-2011 Sakari Bergen <sakari.bergen@beatwaves.net>
3  * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
6  * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __ardour_export_timespan_h__
24 #define __ardour_export_timespan_h__
25
26 #include <string>
27
28 #include <boost/shared_ptr.hpp>
29
30 #include "ardour/libardour_visibility.h"
31 #include "ardour/types.h"
32
33 namespace ARDOUR
34 {
35
36 class ExportStatus;
37 class ExportChannel;
38 class ExportTempFile;
39
40 class LIBARDOUR_API ExportTimespan
41 {
42 private:
43         typedef boost::shared_ptr<ExportStatus> ExportStatusPtr;
44
45 private:
46         friend class ExportElementFactory;
47         ExportTimespan (ExportStatusPtr status, samplecnt_t sample_rate);
48
49 public:
50         ~ExportTimespan ();
51
52         std::string name () const { return _name; }
53         void set_name (std::string name) { _name = name; }
54
55         std::string range_id () const { return _range_id; }
56         void set_range_id (std::string range_id) { _range_id = range_id; }
57
58         bool realtime () const { return _realtime; }
59         void set_realtime (bool rt) { _realtime = rt; }
60
61         void set_range (samplepos_t start, samplepos_t end);
62         samplecnt_t get_length () const { return end_sample - start_sample; }
63         samplepos_t get_start () const { return start_sample; }
64         samplepos_t get_end () const { return end_sample; }
65
66         /// Primarily compare start time, then end time
67         bool operator< (ExportTimespan const & other) {
68                 if (start_sample < other.start_sample) { return true; }
69                 if (start_sample > other.start_sample) { return false; }
70                 return end_sample < other.end_sample;
71         }
72
73 private:
74
75         ExportStatusPtr status;
76
77         samplepos_t start_sample;
78         samplepos_t end_sample;
79         samplepos_t position;
80         samplecnt_t sample_rate;
81
82         std::string _name;
83         std::string _range_id;
84         bool        _realtime;
85
86 };
87
88 } // namespace ARDOUR
89
90 #endif /* __ardour_export_timespan_h__ */