2 repeated-music-iterator.cc -- implement Folded_repeat_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 Folded repeats are a stupid idea at this point, so we refrain from
13 implementing get_music () and skip ().
16 #include "folded-repeat-iterator.hh"
17 #include "repeated-music.hh"
18 #include "music-list.hh"
19 #include "simultaneous-music-iterator.hh"
20 #include "translator-group.hh"
22 Folded_repeat_iterator::Folded_repeat_iterator ()
25 alternative_iter_p_ = 0;
29 Folded_repeat_iterator::ok () const
31 return main_iter_p_ || alternative_iter_p_;
34 Folded_repeat_iterator::~Folded_repeat_iterator ()
37 delete alternative_iter_p_;
41 Folded_repeat_iterator::pending_moment () const
45 return main_iter_p_->pending_moment ();
48 return main_length_mom_ + alternative_iter_p_->pending_moment ();
52 Folded_repeat_iterator::construct_children ()
54 Repeated_music * mus = dynamic_cast<Repeated_music*> (music_l_);
55 main_iter_p_ = get_iterator_p (mus->body ());
56 if (!main_iter_p_->ok())
64 Folded_repeat_iterator::process (Moment m)
68 bool success = try_music (music_l_);
70 music_l_->origin ()->warning ( _("no one to print a repeat brace"));
75 main_iter_p_->process (m);
76 if (!main_iter_p_->ok ())
80 if (!main_iter_p_ && !alternative_iter_p_)
85 if (alternative_iter_p_)
87 alternative_iter_p_->process (m - main_length_mom_);
88 if (!alternative_iter_p_->ok ())
90 delete alternative_iter_p_;
91 alternative_iter_p_ =0;
97 Folded_repeat_iterator::leave_body ()
99 Repeated_music * mus = dynamic_cast<Repeated_music *> (music_l_);
102 main_length_mom_ += mus->body ()->length_mom ();
106 Folded_repeat_iterator::enter_alternative ()
108 Repeated_music * mus = dynamic_cast<Repeated_music *> (music_l_);
109 if (mus->alternatives ())
111 Simultaneous_music_iterator * s = new Simultaneous_music_iterator;
112 s->separate_contexts_b_ = true;
113 s->init_translator (mus->alternatives (), report_to_l ());
115 alternative_iter_p_ = s;
116 alternative_iter_p_->construct_children ();
122 Folded_repeat_iterator::try_music_in_children (Music * m) const
126 return main_iter_p_->try_music (m);
128 if (alternative_iter_p_)
129 return alternative_iter_p_->try_music (m);