X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fsequential-music-iterator.cc;h=bc00a33e12c3a4e57cf822e5cf8d427dfaf0f298;hb=0568120713137e8d51f39f2a95f57c8e8cb5587d;hp=eb572cd81775f1344b8ddd9ddf5c884884af0836;hpb=5360299c83e55dfd2e8e43ff5b999afd67544877;p=lilypond.git diff --git a/lily/sequential-music-iterator.cc b/lily/sequential-music-iterator.cc index eb572cd817..bc00a33e12 100644 --- a/lily/sequential-music-iterator.cc +++ b/lily/sequential-music-iterator.cc @@ -3,171 +3,23 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1999 Han-Wen Nienhuys + (c) 1997--2004 Han-Wen Nienhuys */ -#include "grace-iterator.hh" -#include "translator-group.hh" -#include "debug.hh" -#include "sequential-music-iterator.hh" -#include "music-list.hh" -// hmm -//#include "request-chord-iterator.hh" -#include "request-iterator.hh" - -void -Sequential_music_iterator::do_print() const -{ - if (iter_p_) - iter_p_->print(); -} - -Sequential_music_iterator::Sequential_music_iterator () -{ - cursor_ = 0; - here_mom_ = 0; - iter_p_ =0; - per_elt_b_ = false; -} - -void -Sequential_music_iterator::construct_children() -{ - cursor_ = dynamic_cast (music_l_)->music_p_list_p_->head_; - - while (cursor_) - { - start_next_element(); - if (!iter_p_->ok()) - { - leave_element(); - } - else - { - set_sequential_music_translator(); - break; - } - } -} - -void -Sequential_music_iterator::leave_element() -{ - delete iter_p_; - iter_p_ =0; - Moment elt_time = cursor_->car_->length_mom (); - here_mom_ += elt_time; - cursor_ =cursor_->next_; -} - -void -Sequential_music_iterator::start_next_element() -{ - assert (!iter_p_); - iter_p_ = get_iterator_p (cursor_->car_); -} - -void -Sequential_music_iterator::set_sequential_music_translator() -{ - if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i () - && ! dynamic_cast (iter_p_)) // UGH.! - set_translator (iter_p_->report_to_l()); -} - -Sequential_music_iterator::~Sequential_music_iterator() -{ - assert (! iter_p_); -} - - - - -void -Sequential_music_iterator::do_process_and_next (Moment until) -{ - if (!iter_p_) - return; - while (1) - { - Moment local_until = until - here_mom_; - while (iter_p_->ok()) - { - Moment here = iter_p_->next_moment(); - if (here != local_until) - goto loopexit; - - iter_p_->process_and_next (local_until); - } - - if (!iter_p_->ok()) - { - leave_element(); - - if (cursor_) - { - start_next_element(); - set_sequential_music_translator(); +#include "context.hh" - if (per_elt_b_) - goto loopexit; // ugh. - } - else - { - goto loopexit; - } - } - } -loopexit: +#include "warn.hh" +#include "sequential-music-iterator.hh" +#include "music-list.hh" - Music_iterator::do_process_and_next (until); -} -Moment -Sequential_music_iterator::next_moment() const -{ - return iter_p_->next_moment() + here_mom_; -} -Music* -Sequential_music_iterator::next_music_l () -{ - if (!iter_p_) - return 0; - while (1) - { - if (Music* m = iter_p_->next_music_l ()) - { - return m; - } - else - { - // urg FIXME: sequential children should be iterated to finish - if (dynamic_cast (iter_p_)) - delete iter_p_; - iter_p_ = 0; - leave_element (); - - if (cursor_) - { - start_next_element (); - set_sequential_music_translator (); - } - else - { - delete iter_p_; - iter_p_ = 0; - return 0; - } - } - } -} +IMPLEMENT_CTOR_CALLBACK (Sequential_music_iterator); -bool -Sequential_music_iterator::ok() const +SCM +Sequential_music_iterator::get_music_list ()const { - return iter_p_; + return dynamic_cast (get_music ())->music_list (); } -