2 music-iterator.cc -- implement Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 UGH. too many includes.
13 #include "music-list.hh"
14 #include "music-iterator.hh"
15 #include "property-iterator.hh"
16 #include "request-chord-iterator.hh"
17 #include "sequential-music-iterator.hh"
18 #include "simultaneous-music-iterator.hh"
19 #include "translator-group.hh"
20 #include "translation-property.hh"
21 #include "change-iterator.hh"
22 #include "change-translator.hh"
23 #include "music-wrapper.hh"
24 #include "music-wrapper-iterator.hh"
25 #include "time-scaled-music-iterator.hh"
26 #include "time-scaled-music.hh"
27 #include "context-specced-music.hh"
28 #include "repeated-music.hh"
29 #include "folded-repeat-iterator.hh"
30 #include "unfolded-repeat-iterator.hh"
31 #include "grace-iterator.hh"
32 #include "grace-music.hh"
33 #include "lyric-combine-music.hh"
34 #include "lyric-combine-music-iterator.hh"
35 #include "auto-change-music.hh"
36 #include "auto-change-iterator.hh"
38 #include "request-iterator.hh"
39 #include "output-property.hh"
40 #include "chord-tremolo-iterator.hh"
43 Music_iterator::do_print() const
48 Music_iterator::print() const
53 DEBUG_OUT
<< classname(this) << "{";
54 Translator_group
*t
= report_to_l();
55 DEBUG_OUT
<< "report to " << t
->type_str_
<< " = " << t
->id_str_
<< "\n";
57 DEBUG_OUT
<< "next at " << next_moment() << " ";
59 DEBUG_OUT
<< "not feeling well today..";
66 Music_iterator::get_req_translator_l()
68 assert (report_to_l());
69 if (report_to_l()->is_bottom_translator_b ())
72 set_translator (report_to_l()->get_default_interpreter ());
78 Music_iterator::report_to_l() const
80 return handle_
.report_to_l ();
85 Music_iterator::set_translator (Translator_group
*trans
)
87 handle_
.set_translator (trans
);
91 Music_iterator::construct_children()
95 Music_iterator::~Music_iterator()
100 Music_iterator::next_moment() const
107 Music_iterator::process_and_next (Moment m
)
109 do_process_and_next (m
);
113 Music_iterator::do_process_and_next (Moment
)
119 Music_iterator::ok() const
125 Music_iterator::static_get_iterator_p (Music
const *m
)
127 Music_iterator
* p
=0;
129 /* It would be nice to do this decentrally, but the order of this is
131 if (dynamic_cast<Request_chord
const *> (m
))
132 p
= new Request_chord_iterator
;
133 else if (dynamic_cast<Lyric_combine_music
const*> (m
))
134 p
= new Lyric_combine_music_iterator
;
135 else if (dynamic_cast<Simultaneous_music
const *> (m
))
136 p
= new Simultaneous_music_iterator
;
137 else if (dynamic_cast<Sequential_music
const *> (m
))
138 p
= new Sequential_music_iterator
;
139 else if (dynamic_cast<Translation_property
const *> (m
))
140 p
= new Property_iterator
;
141 else if (dynamic_cast<Change_translator
const *> (m
))
142 p
= new Change_iterator
;
143 else if (dynamic_cast<Time_scaled_music
const *> (m
))
144 p
= new Time_scaled_music_iterator
;
145 else if (dynamic_cast<Grace_music
const*> (m
))
146 p
= new Grace_iterator
;
147 else if (dynamic_cast<Auto_change_music
const*> (m
))
148 p
= new Auto_change_iterator
;
149 else if (dynamic_cast<Music_wrapper
const *> (m
))
150 p
= new Music_wrapper_iterator
;
151 else if (Repeated_music
const * n
= dynamic_cast<Repeated_music
const *> (m
))
153 if (n
->type_
== "tremolo")
154 p
= new Chord_tremolo_iterator
;
156 p
= new Folded_repeat_iterator
;
158 p
= new Unfolded_repeat_iterator
;
162 p
= new Simple_music_iterator
;
170 Music_iterator::init_translator (Music
const *m
, Translator_group
*report_l
)
173 if (Context_specced_music
const * csm
=dynamic_cast<Context_specced_music
const*>(m
))
175 Translator_group
* a
=report_l
->
176 find_create_translator_l (csm
->translator_type_str_
, csm
->translator_id_str_
);
183 set_translator (report_l
);
188 Music_iterator::get_iterator_p (Music
const*m
) const
190 Music_iterator
*p
= static_get_iterator_p (m
);
191 p
->init_translator (m
, report_to_l());
193 p
->construct_children();
197 Music_iterator::Music_iterator()
203 Music_iterator::try_music (Music
const *m
) const
205 bool b
= report_to_l ()->try_music ((Music
*)m
); // ugh
206 Music_iterator
* it
= b
? (Music_iterator
*) this : 0; // ugh
208 it
= try_music_in_children (m
);
213 Music_iterator::try_music_in_children (Music
const * ) const