ChanCount(DataType type, size_t channels)
{
reset();
- set_count(type, channels);
+ set(type, channels);
}
void reset()
_counts[(*t).to_index()] = 0;
}
}
+
+ // -1 is what to_index does. inlined for speed. this should maybe be changed..
+ inline size_t n_audio() const { return _counts[DataType::AUDIO-1]; }
+ inline size_t n_midi() const { return _counts[DataType::MIDI-1]; }
- void set_count(DataType type, size_t count) { _counts[type.to_index()] = count; }
- size_t get_count(DataType type) const { return _counts[type.to_index()]; }
+ 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_count() const
+ size_t get_total() const
{
size_t ret = 0;
for (size_t i=0; i < DataType::num_types; ++i)
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];
};