2 unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "new-repeated-music.hh"
12 #include "music-list.hh"
13 #include "unfolded-repeat-iterator.hh"
15 #include "translator-group.hh"
17 Unfolded_repeat_iterator::~Unfolded_repeat_iterator ()
19 delete current_iter_p_;
22 Unfolded_repeat_iterator::Unfolded_repeat_iterator ()
31 If we are in the body of the repeat always go to the current alternative.
33 If we are not in the body, then we are in an alternative. If we are
34 fully unfolding, advance the current alternative and go back to main.
35 If we are semi-unfolding, advance the current alternative, and go to
36 the alternative just set.
40 Unfolded_repeat_iterator::next_element ()
42 New_repeated_music const* mus =dynamic_cast<New_repeated_music const*> (music_l_);
43 delete current_iter_p_;
49 done_mom_ += mus->repeat_body_p_->length_mom ();
50 if (alternative_cons_l_)
52 current_iter_p_ = get_iterator_p (alternative_cons_l_->car_);
58 if (alternative_cons_l_)
60 done_mom_ += alternative_cons_l_->car_->length_mom ();
61 alternative_cons_l_ = alternative_cons_l_->next_;
65 if (done_count_ < mus->repeats_i_ && alternative_cons_l_)
67 if (mus->semi_fold_b_)
68 current_iter_p_ = get_iterator_p (alternative_cons_l_->car_);
71 current_iter_p_ = get_iterator_p (mus->repeat_body_p_);
79 Unfolded_repeat_iterator::ok () const
81 return current_iter_p_ ;
85 Unfolded_repeat_iterator::next_moment () const
87 return done_mom_ + current_iter_p_->next_moment ();
91 Unfolded_repeat_iterator::construct_children ()
93 New_repeated_music const* mus =dynamic_cast<New_repeated_music const*> (music_l_);
94 alternative_cons_l_ = (mus->alternatives_p_)
95 ? mus->alternatives_p_->music_p_list_p_->head_
98 if (mus->repeat_body_p_)
100 current_iter_p_ = get_iterator_p (mus->repeat_body_p_);
103 else if (alternative_cons_l_)
105 current_iter_p_ = get_iterator_p (alternative_cons_l_->car_);
111 Unfolded_repeat_iterator::do_process_and_next (Moment m)
115 bool success = report_to_l ()->try_music (music_l_);
117 music_l_->warning ( _("No one to print a volta bracket"));
121 while (!current_iter_p_->ok ())
125 if (!current_iter_p_)
129 if (m - done_mom_ >= current_iter_p_->next_moment ())
130 current_iter_p_->process_and_next (m - done_mom_);
137 Unfolded_repeat_iterator::do_print () const
140 DOUT << "count " << done_count_ << "done time " << done_mom_ << '\n';
142 current_iter_p_->print();