2 change-iterator.cc -- implement Change_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "change-iterator.hh"
10 #include "translator-group.hh"
11 #include "change-translator.hh"
16 Change_iterator::error (String reason)
18 Change_translator const * t = dynamic_cast<Change_translator const*> (music_l_);
19 String to_type = t->change_to_type_str_;
20 String to_id = t->change_to_id_str_;
22 String warn1 = _f ("can't change `%s\' to `%s\'", to_type, to_id)
24 String warn2= "Change_iterator::do_process_and_next (): "
25 + report_to_l ()->type_str_ + " = `"
26 + report_to_l ()->id_str_ + "\': ";
32 move to construct_children ?
35 Change_iterator::do_process_and_next (Moment m)
37 Translator_group * current = report_to_l ();
38 Translator_group * last = 0;
40 Change_translator const * t = dynamic_cast<Change_translator const*> (music_l_);
41 String to_type = t->change_to_type_str_;
42 String to_id = t->change_to_id_str_;
44 /* find the type of translator that we're changing.
46 If \translator Staff = bass, then look for Staff = *
48 while (current && current->type_str_ != to_type)
51 current = current->daddy_trans_l_;
58 Translator_group * dest =
59 report_to_l ()->find_create_translator_l (to_type, to_id);
60 current->remove_translator_p (last);
61 dest->add_translator (last);
66 We could change the current translator's id, but that would make
69 last->translator_id_str_ = change_l ()->change_to_id_str_;
71 error ("I'm one myself");
74 error ("None of these in my family.");
75 Music_iterator::do_process_and_next (m);