2 music-iterator.cc -- implement Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "music-list.hh"
10 #include "music-iterator.hh"
11 #include "property-iterator.hh"
12 #include "request-chord-iterator.hh"
13 #include "sequential-music-iterator.hh"
14 #include "simultaneous-music-iterator.hh"
15 #include "translator-group.hh"
16 #include "translation-property.hh"
17 #include "change-iterator.hh"
18 #include "change-translator.hh"
19 #include "music-wrapper.hh"
20 #include "music-wrapper-iterator.hh"
21 #include "time-scaled-music-iterator.hh"
22 #include "time-scaled-music.hh"
23 #include "context-specced-music.hh"
24 #include "repeated-music.hh"
25 #include "folded-repeat-iterator.hh"
26 #include "unfolded-repeat-iterator.hh"
27 #include "grace-iterator.hh"
28 #include "grace-music.hh"
29 #include "lyric-combine-music.hh"
30 #include "lyric-combine-music-iterator.hh"
31 #include "auto-change-music.hh"
32 #include "auto-change-iterator.hh"
35 Music_iterator::do_print() const
40 Music_iterator::print() const
45 DEBUG_OUT
<< classname(this) << "{";
46 Translator_group
*t
= report_to_l();
47 DEBUG_OUT
<< "report to " << t
->type_str_
<< " = " << t
->id_str_
<< "\n";
49 DEBUG_OUT
<< "next at " << next_moment() << " ";
51 DEBUG_OUT
<< "not feeling well today..";
58 Music_iterator::get_req_translator_l()
60 assert (report_to_l());
61 if (report_to_l()->is_bottom_translator_b ())
64 set_translator (report_to_l()->get_default_interpreter ());
70 Music_iterator::report_to_l() const
72 return handle_
.report_to_l ();
77 Music_iterator::set_translator (Translator_group
*trans
)
79 handle_
.set_translator (trans
);
83 Music_iterator::construct_children()
87 Music_iterator::~Music_iterator()
92 Music_iterator::next_moment() const
99 Music_iterator::process_and_next (Moment m
)
101 do_process_and_next (m
);
105 Music_iterator::do_process_and_next (Moment
)
111 Music_iterator::ok() const
117 Music_iterator::static_get_iterator_p (Music
const *m
)
119 Music_iterator
* p
=0;
121 /* It would be nice to do this decentrally, but the order of this is
123 if (dynamic_cast<Request_chord
const *> (m
))
124 p
= new Request_chord_iterator
;
125 else if (dynamic_cast<Lyric_combine_music
const*> (m
))
126 p
= new Lyric_combine_music_iterator
;
127 else if (dynamic_cast<Simultaneous_music
const *> (m
))
128 p
= new Simultaneous_music_iterator
;
129 else if (dynamic_cast<Sequential_music
const *> (m
))
130 p
= new Sequential_music_iterator
;
131 else if (dynamic_cast<Translation_property
const *> (m
))
132 p
= new Property_iterator
;
133 else if (dynamic_cast<Change_translator
const *> (m
))
134 p
= new Change_iterator
;
135 else if (dynamic_cast<Time_scaled_music
const *> (m
))
136 p
= new Time_scaled_music_iterator
;
137 else if (dynamic_cast<Grace_music
const*> (m
))
138 p
= new Grace_iterator
;
139 else if (dynamic_cast<Auto_change_music
const*> (m
))
140 p
= new Auto_change_iterator
;
141 else if (dynamic_cast<Music_wrapper
const *> (m
))
142 p
= new Music_wrapper_iterator
;
143 else if (Repeated_music
const * n
= dynamic_cast<Repeated_music
const *> (m
))
146 p
= new Folded_repeat_iterator
;
148 p
= new Unfolded_repeat_iterator
;
159 Music_iterator::init_translator (Music
const *m
, Translator_group
*report_l
)
162 if (Context_specced_music
const * csm
=dynamic_cast<Context_specced_music
const*>(m
))
164 Translator_group
* a
=report_l
->
165 find_create_translator_l (csm
->translator_type_str_
, csm
->translator_id_str_
);
172 set_translator (report_l
);
177 Music_iterator::get_iterator_p (Music
const*m
) const
179 Music_iterator
*p
= static_get_iterator_p (m
);
180 p
->init_translator (m
, report_to_l());
182 p
->construct_children();
186 Music_iterator::Music_iterator()
192 Music_iterator::try_music (Music
const *m
) const
194 bool b
= report_to_l ()->try_music ((Music
*)m
); // ugh
195 Music_iterator
* it
= b
? (Music_iterator
*) this : 0; // ugh
197 it
= try_music_in_children (m
);
202 Music_iterator::try_music_in_children (Music
const * ) const