5394 |
* @param dst - destination instrument at which this instrument will be |
* @param dst - destination instrument at which this instrument will be |
5395 |
* moved to, or pass NULL for moving to end of list |
* moved to, or pass NULL for moving to end of list |
5396 |
* @throw gig::Exception if this instrument and target instrument are not |
* @throw gig::Exception if this instrument and target instrument are not |
5397 |
* part of the same file |
* part of the same file, as well as on unexpected |
5398 |
|
* internal error |
5399 |
*/ |
*/ |
5400 |
void Instrument::MoveTo(Instrument* dst) { |
void Instrument::MoveTo(Instrument* dst) { |
5401 |
if (dst && GetParent() != dst->GetParent()) |
if (dst && GetParent() != dst->GetParent()) |
5412 |
|
|
5413 |
File::InstrumentList::iterator itFrom = |
File::InstrumentList::iterator itFrom = |
5414 |
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(this)); |
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(this)); |
5415 |
|
if (itFrom == list.end()) |
5416 |
|
throw Exception( |
5417 |
|
"gig::Instrument::MoveTo(): unexpected missing membership " |
5418 |
|
"of this instrument." |
5419 |
|
); |
5420 |
|
list.erase(itFrom); |
5421 |
|
|
5422 |
File::InstrumentList::iterator itTo = |
File::InstrumentList::iterator itTo = |
5423 |
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(dst)); |
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(dst)); |
5424 |
|
|
5425 |
list.splice(itTo, list, itFrom); |
list.insert(itTo, this); |
5426 |
} |
} |
5427 |
|
|
5428 |
// move the instrument's actual list RIFF chunk appropriately |
// move the instrument's actual list RIFF chunk appropriately |