MIDI region forking, plus Playlist::regions_to_read() fix forward ported from 2.X...
[ardour.git] / libs / ardour / ardour / bbt_time.h
1 /*
2     Copyright (C) 2002-2009 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_bbt_time_h__
21 #define __ardour_bbt_time_h__
22
23 #include <ostream>
24 #include <stdint.h>
25
26 namespace ARDOUR {
27
28 struct BBT_Time {
29     uint32_t bars;
30     uint32_t beats;
31     uint32_t ticks;
32     
33     BBT_Time() {
34             bars = 1;
35             beats = 1;
36             ticks = 0;
37     }
38     
39     BBT_Time (uint32_t ba, uint32_t be, uint32_t t)
40          : bars (ba), beats (be), ticks (t) {}
41
42     bool operator< (const BBT_Time& other) const {
43             return bars < other.bars ||
44                     (bars == other.bars && beats < other.beats) ||
45                     (bars == other.bars && beats == other.beats && ticks < other.ticks);
46     }
47     
48     bool operator== (const BBT_Time& other) const {
49             return bars == other.bars && beats == other.beats && ticks == other.ticks;
50     }
51 };
52
53 }
54
55 inline std::ostream&
56 operator<< (std::ostream& o, const ARDOUR::BBT_Time& bbt)
57 {
58         o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks;
59         return o;
60 }
61
62 #endif /* __ardour_bbt_time_h__ */