Line data Source code
1 : #include "MIDICNChannelAddress.hpp" 2 : 3 : BEGIN_CS_NAMESPACE 4 : 5 : MIDICNChannelAddress &MIDICNChannelAddress:: 6 89 : operator+=(const RelativeMIDICNChannelAddress &rhs) { 7 89 : if (!this->isValid() || !rhs.isValid()) { 8 2 : this->addresses.valid = false; 9 2 : } else { 10 87 : this->addresses.address += rhs.addresses.address; 11 87 : this->addresses.channel += rhs.addresses.channel; 12 87 : this->addresses.cableNumber += rhs.addresses.cableNumber; 13 : } 14 89 : return *this; 15 : } 16 : 17 : MIDICNChannelAddress &MIDICNChannelAddress:: 18 4 : operator-=(const RelativeMIDICNChannelAddress &rhs) { 19 4 : if (!this->isValid() || !rhs.isValid()) { 20 2 : this->addresses.valid = false; 21 2 : } else { 22 2 : this->addresses.address -= rhs.addresses.address; 23 2 : this->addresses.channel -= rhs.addresses.channel; 24 2 : this->addresses.cableNumber -= rhs.addresses.cableNumber; 25 : } 26 4 : return *this; 27 : } 28 : 29 : MIDICNChannelAddress MIDICNChannelAddress:: 30 37 : operator+(const RelativeMIDICNChannelAddress &rhs) const { 31 37 : MIDICNChannelAddress copy = *this; 32 37 : copy += rhs; 33 37 : return copy; 34 : } 35 : 36 : MIDICNChannelAddress MIDICNChannelAddress:: 37 1 : operator-(const RelativeMIDICNChannelAddress &rhs) const { 38 1 : MIDICNChannelAddress copy = *this; 39 1 : copy -= rhs; 40 1 : return copy; 41 : } 42 : 43 12 : bool MIDICNChannelAddress::matchSingle(const MIDICNChannelAddress &toMatch, 44 : const MIDICNChannelAddress &base) { 45 12 : return base == toMatch; 46 : } 47 : 48 80 : bool MIDICNChannelAddress::matchAddressInRange( 49 : const MIDICNChannelAddress &toMatch, const MIDICNChannelAddress &base, 50 : uint8_t length) { 51 80 : bool valid = base.addresses.valid && toMatch.addresses.valid; 52 80 : bool addressInRange = 53 80 : base.addresses.address <= toMatch.addresses.address && 54 80 : base.addresses.address + length > toMatch.addresses.address; 55 80 : bool equalChannelAndCN = 56 80 : base.addresses.channel == toMatch.addresses.channel && 57 80 : base.addresses.cableNumber == toMatch.addresses.cableNumber; 58 80 : return valid && addressInRange && equalChannelAndCN; 59 : } 60 : 61 : END_CS_NAMESPACE