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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/*
Copyright (C) 2006 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.
$Id: insert.cc 712 2006-07-28 01:08:57Z drobilla $
*/
#ifndef __ardour_chan_count_h__
#define __ardour_chan_count_h__
#include <ardour/data_type.h>
namespace ARDOUR {
class ChanCount {
public:
ChanCount() { reset(); }
// Convenience constructor for making single-typed streams (stereo, mono, etc)
ChanCount(DataType type, size_t channels)
{
reset();
set(type, channels);
}
void reset()
{
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
_counts[(*t).to_index()] = 0;
}
}
void set(DataType type, size_t count) { _counts[type.to_index()] = count; }
size_t get(DataType type) const { return _counts[type.to_index()]; }
size_t get_total() const
{
size_t ret = 0;
for (size_t i=0; i < DataType::num_types; ++i)
ret += _counts[i];
return ret;
}
bool operator==(const ChanCount& other) const
{
for (size_t i=0; i < DataType::num_types; ++i)
if (_counts[i] != other._counts[i])
return false;
return true;
}
bool operator!=(const ChanCount& other) const
{
return ! (*this == other);
}
bool operator<(const ChanCount& other) const
{
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
if (_counts[(*t).to_index()] > other._counts[(*t).to_index()]) {
return false;
}
}
return (*this != other);
}
bool operator<=(const ChanCount& other) const
{
return ( (*this < other) || (*this == other) );
}
bool operator>(const ChanCount& other) const
{
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
if (_counts[(*t).to_index()] < other._counts[(*t).to_index()]) {
return false;
}
}
return (*this != other);
}
bool operator>=(const ChanCount& other) const
{
return ( (*this > other) || (*this == other) );
}
static const ChanCount INFINITE;
static const ChanCount ZERO;
private:
size_t _counts[DataType::num_types];
};
} // namespace ARDOUR
#endif // __ardour_chan_count_h__
|