2 Sequential_music_iterator.cc -- implement Sequential_music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "grace-iterator.hh"
9 #include "translator-group.hh"
11 #include "sequential-music-iterator.hh"
12 #include "music-list.hh"
13 #include "request-chord-iterator.hh"
15 Sequential_music_iterator::Sequential_music_iterator ()
22 Sequential_music_iterator::Sequential_music_iterator (Sequential_music_iterator const &src)
23 : Music_iterator (src)
25 cursor_ = src.cursor_;
26 here_mom_ = src.here_mom_;
27 iter_p_ = src.iter_p_->clone ();
30 Sequential_music_iterator::~Sequential_music_iterator()
35 music_l_->origin ()->warning (_ ("Must stop before this music ends"));
42 Sequential_music_iterator::do_print() const
49 Sequential_music_iterator::construct_children()
51 cursor_ = dynamic_cast<Music_sequence const*> (music_l_)->music_list ();
53 while (gh_pair_p (cursor_ ))
62 set_sequential_music_translator();
69 Sequential_music_iterator::leave_element()
73 Moment elt_time = unsmob_music (gh_car (cursor_))->length_mom ();
74 here_mom_ += elt_time;
75 cursor_ =gh_cdr (cursor_);
79 Sequential_music_iterator::start_next_element()
82 iter_p_ = get_iterator_p (unsmob_music (gh_car (cursor_)));
86 Sequential_music_iterator::set_sequential_music_translator()
88 Translator_group * child_report = child_report = iter_p_->report_to_l ();
89 if (dynamic_cast<Grace_iterator*> (iter_p_))
90 child_report = child_report->daddy_trans_l_;
92 if (report_to_l()->depth_i () < child_report->depth_i ())
93 set_translator (child_report);
97 Sequential_music_iterator::get_music ()
100 return unsmob_music (gh_car (cursor_));
106 Sequential_music_iterator::next ()
112 b = iter_p_->next ();
115 set_sequential_music_translator ();
117 if (gh_pair_p (cursor_))
118 start_next_element ();
127 This should use get_music () and next ()
130 Sequential_music_iterator::do_process_and_next (Moment until)
136 Moment local_until = until - here_mom_;
137 while (iter_p_->ok ())
139 Moment here = iter_p_->next_moment ();
140 if (here != local_until)
141 return Music_iterator::do_process_and_next (until);
143 iter_p_->process_and_next (local_until);
148 set_sequential_music_translator ();
151 if (gh_pair_p (cursor_))
152 start_next_element ();
154 return Music_iterator::do_process_and_next (until);
161 Sequential_music_iterator::next_moment() const
163 return iter_p_->next_moment() + here_mom_;
168 Sequential_music_iterator::ok() const
174 Sequential_music_iterator::try_music_in_children (Music *m) const
176 return iter_p_ ? iter_p_->try_music (m) : 0;