2 music-iterator.cc -- implement Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "music-list.hh"
10 #include "music-iterator.hh"
11 #include "voice-iterator.hh"
12 #include "chord-iterator.hh"
13 #include "request-iterator.hh"
14 #include "translator.hh"
17 IMPLEMENT_IS_TYPE_B(Music_iterator
);
21 Music_iterator::do_print() const
27 Music_iterator::print() const
32 DOUT
<< name() << "{";
33 DOUT
<< "report to " <<
34 report_to_l() << " (" << report_to_l ()->name () << ")\n";
36 DOUT
<< "next at " << next_moment() << " ";
38 DOUT
<< "not feeling well today..";
45 Music_iterator::get_req_translator_l()
47 assert (report_to_l());
48 if (report_to_l()->is_bottom_engraver_b ())
51 set_translator (report_to_l()->get_default_interpreter ());
56 Music_iterator::push_translator (Translator
*t
)
58 report_to_l_arr_
.push (t
);
59 t
->iterator_count_
++;
63 Music_iterator::pop_translator()
65 report_to_l()->iterator_count_
--;
66 assert (report_to_l()->iterator_count_
>=0);
67 report_to_l_arr_
.pop();
71 Music_iterator::report_to_l() const
73 if (! report_to_l_arr_
.size())
75 return report_to_l_arr_
.top();
80 Music_iterator::set_translator (Translator
*trans
)
82 if (report_to_l()==trans
)
87 push_translator (trans
);
91 Music_iterator::construct_children()
96 Music_iterator::~Music_iterator()
102 Music_iterator::next_moment() const
108 Music_iterator::process_and_next (Moment
)
114 Music_iterator::ok() const
120 Music_iterator::static_get_iterator_p (Music
*m
,
121 Translator
*report_l
)
123 Music_iterator
* p
=0;
124 if (m
->is_type_b (Request_chord::static_name()))
125 p
= new Request_chord_iterator ((Request_chord
*) m
);
126 else if (m
->is_type_b (Chord::static_name()))
127 p
= new Chord_iterator ((Chord
*) m
);
128 else if (m
->is_type_b (Voice::static_name()))
129 p
= new Voice_iterator ((Voice
*) m
);
131 if (m
-> type_str_
!= "")
133 Translator
* a
=report_l
->
134 find_get_translator_l (m
-> type_str_
, m
->id_str_
);
135 p
->set_translator (a
);
139 if (! p
->report_to_l())
140 p
->set_translator (report_l
);
146 Music_iterator::get_iterator_p (Music
*m
) const
148 Music_iterator
*p
= static_get_iterator_p (m
,report_to_l());
149 p
->daddy_iter_l_
= (Music_iterator
*)this;
150 p
->construct_children();
154 Music_iterator::Music_iterator()