2 music-iterator.cc -- implement Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "music-list.hh"
10 #include "music-iterator.hh"
11 #include "voice-iterator.hh"
12 #include "property-iterator.hh"
13 #include "chord-iterator.hh"
14 #include "request-iterator.hh"
15 #include "translator-group.hh"
16 #include "translation-property.hh"
17 #include "change-iterator.hh"
18 #include "change-translator.hh"
20 #include "music-wrapper.hh"
21 #include "music-wrapper-iterator.hh"
24 IMPLEMENT_IS_TYPE_B(Music_iterator);
28 Music_iterator::do_print() const
34 Music_iterator::print() const
39 DOUT << name() << "{";
40 DOUT << "report to " <<
41 report_to_l() << " (" << report_to_l ()->name () << ")\n";
43 DOUT << "next at " << next_moment() << " ";
45 DOUT << "not feeling well today..";
52 Music_iterator::get_req_translator_l()
54 assert (report_to_l());
55 if (report_to_l()->is_bottom_translator_b ())
58 set_translator (report_to_l()->get_default_interpreter ());
63 Music_iterator::push_translator (Translator_group*t)
65 report_to_l_arr_.push (t);
66 t->iterator_count_ ++;
70 Music_iterator::pop_translator()
72 report_to_l()->iterator_count_ --;
73 assert (report_to_l()->iterator_count_ >=0);
74 report_to_l_arr_.pop();
78 Music_iterator::report_to_l() const
80 if (! report_to_l_arr_.size())
82 return report_to_l_arr_.top();
87 Music_iterator::set_translator (Translator_group*trans)
89 if (report_to_l()==trans)
94 push_translator (trans);
98 Music_iterator::construct_children()
103 Music_iterator::~Music_iterator()
109 Music_iterator::next_moment() const
115 Music_iterator::process_and_next (Moment)
122 Music_iterator::ok() const
128 Music_iterator::static_get_iterator_p (Music *m,
129 Translator_group*report_l)
131 Music_iterator * p =0;
132 if (m->is_type_b (Request_chord::static_name()))
133 p = new Request_chord_iterator ((Request_chord*) m);
134 else if (m->is_type_b (Chord::static_name()))
135 p = new Chord_iterator ((Chord*) m);
136 else if (m->is_type_b (Voice::static_name()))
137 p = new Voice_iterator ((Voice*) m);
138 else if (m->is_type_b (Translation_property::static_name ()))
139 p = new Property_iterator((Translation_property *) m);
140 else if (m->is_type_b (Change_translator::static_name ()))
141 p = new Change_iterator((Change_translator*) m);
142 else if (m->is_type_b (Music_wrapper::static_name ()))
143 p = new Music_wrapper_iterator ((Music_wrapper *)m);
146 if (m -> translator_type_str_.length_i ())
148 Translator_group* a =report_l->
149 find_create_translator_l (m-> translator_type_str_, m->translator_id_str_);
150 p->set_translator (a);
153 if (! p->report_to_l())
154 p ->set_translator (report_l);
160 Music_iterator::get_iterator_p (Music*m) const
162 Music_iterator*p = static_get_iterator_p (m,report_to_l());
163 p->daddy_iter_l_ = (Music_iterator*)this;
164 p->construct_children();
168 Music_iterator::Music_iterator()