X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fsequential-music-iterator.cc;h=f933df7bb43330d82351adf8fae1bd8283444196;hb=cd586e589daa7a550fa39200a78cb2012e853d99;hp=de480844e5b105677b42830671a8caa56cf1f37c;hpb=ce9845392e4e22ae9c5f6ec1da914eb301f1892c;p=lilypond.git diff --git a/lily/sequential-music-iterator.cc b/lily/sequential-music-iterator.cc index de480844e5..f933df7bb4 100644 --- a/lily/sequential-music-iterator.cc +++ b/lily/sequential-music-iterator.cc @@ -1,206 +1,20 @@ /* - Sequential_music_iterator.cc -- implement Sequential_music_iterator + sequential-music-iterator.cc -- implement Sequential_music_iterator source file of the GNU LilyPond music typesetter - (c) 1997--2000 Han-Wen Nienhuys + (c) 1997--2006 Han-Wen Nienhuys */ -#include "grace-iterator.hh" -#include "translator-group.hh" -#include "debug.hh" -#include "sequential-music-iterator.hh" -#include "music-list.hh" -#include "request-chord-iterator.hh" - -Sequential_music_iterator::Sequential_music_iterator () -{ - cursor_ = 0; - here_mom_ = 0; - iter_p_ =0; -} - -Sequential_music_iterator::Sequential_music_iterator (Sequential_music_iterator const &src) - : Music_iterator (src) -{ - cursor_ = src.cursor_; - here_mom_ = src.here_mom_; - if (src.iter_p_) - iter_p_ = src.iter_p_->clone (); - else - iter_p_ = 0; -} - -Sequential_music_iterator::~Sequential_music_iterator() -{ - delete iter_p_; -} - -void -Sequential_music_iterator::construct_children() -{ - cursor_ = dynamic_cast (music_l_)->music_list (); - - while (gh_pair_p (cursor_ )) - { - iter_p_ = get_iterator_p (unsmob_music (gh_car (cursor_))); - - if (iter_p_->ok()) - { - descend_to_child (); - return; - } - - delete iter_p_ ; - iter_p_ =0; - cursor_ = gh_cdr (cursor_); - } -} - /* - move to context of child iterator if it is deeper down in the - hierarchy. - */ - -void -Sequential_music_iterator::descend_to_child () -{ - - Translator_group * child_report = child_report = iter_p_->report_to_l (); - if (dynamic_cast (iter_p_)) - child_report = child_report->daddy_trans_l_; - - if (report_to_l()->depth_i () < child_report->depth_i ()) - set_translator (child_report); -} - - -/* - Retrieve all music (starting at HERE), until a music with length L > - 0 is found. From the precondition, we know that UNTIL is later than - the earliest event. Hence we know - - L >= (UNTIL - HERE) - so something that comes after this thing with L > 0 happens after - - HERE + L >= HERE + (UNTIL - HERE) = UNTIL +#include "context.hh" +#include "sequential-music-iterator.hh" +#include "music.hh" +#include "warn.hh" - Hence all events after the one with L>0 are uninteresting, so we - ignore them. - -*/ +IMPLEMENT_CTOR_CALLBACK (Sequential_music_iterator); SCM -Sequential_music_iterator::get_music (Moment until)const +Sequential_music_iterator::get_music_list ()const { - SCM s = SCM_EOL; - if (until < pending_moment ()) - return s; - - SCM curs = cursor_; - Music_iterator * iter = iter_p_->clone (); - while (1) - { - SCM nm = iter->get_music (until - here_mom_); - s = gh_append2 (nm, s); - - Moment m = 0; - for (SCM i = nm; gh_pair_p(i); i = gh_cdr (i)) - m = m >? unsmob_music (gh_car (i))->length_mom (); - - delete iter; - - curs = gh_cdr (curs); - - if (!gh_pair_p (curs) || m > Moment (0)) - return s; - else - { - iter = get_iterator_p (unsmob_music (gh_car (curs))); - } - } - return s; -} -/* - Skip events till UNTIL. We don't do any other side effects (such as - moving descending to child iterator contexts, because they might - depend on \context specs and \translator changes being executed - - */ -void -Sequential_music_iterator::skip (Moment until) -{ - while (1) - { - Moment l =iter_p_->music_length_mom (); - if (l >= until - here_mom_) - iter_p_->skip (until - here_mom_); - - if (iter_p_->ok ()) - return ; - - here_mom_ = here_mom_ + l; - delete iter_p_; - iter_p_ =0; - - cursor_ = gh_cdr (cursor_); - - if (!gh_pair_p (cursor_)) - return ; - else - iter_p_ = get_iterator_p (unsmob_music (gh_car (cursor_))); - } -} - -void -Sequential_music_iterator::process (Moment until) -{ - while (1) - { - iter_p_->process (until - here_mom_); - - /* - if the iter is still OK, there must be events left that have - - TIME > LEFT - - */ - if (iter_p_->ok ()) - return ; - - here_mom_ += iter_p_->music_length_mom (); - - descend_to_child (); - delete iter_p_; - iter_p_ =0; - - cursor_ = gh_cdr (cursor_); - - if (!gh_pair_p (cursor_)) - return ; - else - { - delete iter_p_; - iter_p_ = get_iterator_p (unsmob_music (gh_car (cursor_))); - } - } - -} - -Moment -Sequential_music_iterator::pending_moment() const -{ - return iter_p_->pending_moment() + here_mom_; -} - - -bool -Sequential_music_iterator::ok() const -{ - return iter_p_; -} - -Music_iterator* -Sequential_music_iterator::try_music_in_children (Music *m) const -{ - return iter_p_ ? iter_p_->try_music (m) : 0; + return get_music ()->get_property ("elements"); }