2 new-repeated-music-iterator.cc -- implement Folded_repeat_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "folded-repeat-iterator.hh"
11 #include "new-repeated-music.hh"
12 #include "music-list.hh"
13 #include "simultaneous-music-iterator.hh"
14 #include "translator-group.hh"
16 Folded_repeat_iterator::Folded_repeat_iterator ()
19 alternative_iter_p_
= 0;
23 Folded_repeat_iterator::ok () const
25 return main_iter_p_
|| alternative_iter_p_
;
28 Folded_repeat_iterator::~Folded_repeat_iterator ()
31 delete alternative_iter_p_
;
35 Folded_repeat_iterator::next_moment () const
39 return main_iter_p_
->next_moment ();
42 return main_length_mom_
+ alternative_iter_p_
->next_moment ();
46 Folded_repeat_iterator::construct_children ()
48 New_repeated_music
const * mus
= dynamic_cast<New_repeated_music
const*> (music_l_
);
49 main_iter_p_
= get_iterator_p (mus
->repeat_body_p_
);
50 if (!main_iter_p_
->ok())
58 Folded_repeat_iterator::do_process_and_next (Moment m
)
62 bool success
= report_to_l ()->try_music (music_l_
);
64 music_l_
->warning ( _("No one to print a volta bracket"));
67 New_repeated_music
const * mus
= dynamic_cast<New_repeated_music
const*> (music_l_
);
71 main_iter_p_
->process_and_next (m
);
72 if (!main_iter_p_
->ok ())
76 if (!main_iter_p_
&& !alternative_iter_p_
)
81 if (alternative_iter_p_
)
83 alternative_iter_p_
->process_and_next (m
- main_length_mom_
);
84 if (!alternative_iter_p_
->ok ())
86 delete alternative_iter_p_
;
87 alternative_iter_p_
=0;
93 Folded_repeat_iterator::leave_body ()
95 New_repeated_music
const * mus
= dynamic_cast<New_repeated_music
const*> (music_l_
);
98 main_length_mom_
+= mus
->repeat_body_p_
->length_mom ();
102 Folded_repeat_iterator::enter_alternative ()
104 New_repeated_music
const * mus
= dynamic_cast<New_repeated_music
const*> (music_l_
);
105 Simultaneous_music_iterator
* s
= new Simultaneous_music_iterator
;
106 s
->separate_contexts_b_
= true;
107 s
->init_translator (mus
->alternatives_p_
, report_to_l ());
109 alternative_iter_p_
= s
;
110 alternative_iter_p_
->construct_children ();
114 Folded_repeat_iterator::do_print () const