2 music-iterator.cc -- implement Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.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)
121 Music_iterator::ok() const
127 Music_iterator::static_get_iterator_p (Music *m,
128 Translator_group*report_l)
130 Music_iterator * p =0;
131 if (m->is_type_b (Request_chord::static_name()))
132 p = new Request_chord_iterator ((Request_chord*) m);
133 else if (m->is_type_b (Chord::static_name()))
134 p = new Chord_iterator ((Chord*) m);
135 else if (m->is_type_b (Voice::static_name()))
136 p = new Voice_iterator ((Voice*) m);
137 else if (m->is_type_b (Translation_property::static_name ()))
138 p = new Property_iterator((Translation_property *) m);
139 else if (m->is_type_b (Change_translator::static_name ()))
140 p = new Change_iterator((Change_translator*) m);
141 else if (m->is_type_b (Music_wrapper::static_name ()))
142 p = new Music_wrapper_iterator ((Music_wrapper *)m);
145 if (m -> translator_type_str_.length_i ())
147 Translator_group* a =report_l->
148 find_create_translator_l (m-> translator_type_str_, m->translator_id_str_);
149 p->set_translator (a);
152 if (! p->report_to_l())
153 p ->set_translator (report_l);
159 Music_iterator::get_iterator_p (Music*m) const
161 Music_iterator*p = static_get_iterator_p (m,report_to_l());
162 p->daddy_iter_l_ = (Music_iterator*)this;
163 p->construct_children();
167 Music_iterator::Music_iterator()