lilypond-0.1.56
[lilypond.git] / lily / change-iterator.cc
blob883e963e9f3d29b00a62c96f353c5bddd8fa5b6d
1 /*
2 change-iterator.cc -- implement Change_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "change-iterator.hh"
10 #include "translator-group.hh"
11 #include "change-translator.hh"
12 #include "debug.hh"
14 Change_iterator::Change_iterator (Change_translator *change_l)
16 change_l_ = change_l;
19 void
20 Change_iterator::error (String reason)
22 String to_type = change_l_->change_to_type_str_;
23 String to_id = change_l_->change_to_id_str_;
25 String warn1 =
26 _ ("Can't change ") + to_type
27 + _(" to ") + "`" + to_id + "\': " + reason;
28 String warn2= "Change_iterator::process_and_next (): " + report_to_l ()->type_str_ + " = `"
29 + report_to_l ()->id_str_ + "\': ";
30 warning (warn2);
31 change_l_->warning (warn1);
35 move to construct_children ?
37 void
38 Change_iterator::process_and_next (Moment m)
40 Translator_group * current = report_to_l ();
41 Translator_group * last = 0;
43 String to_type = change_l_->change_to_type_str_;
44 String to_id = change_l_->change_to_id_str_;
46 /* find the type of translator that we're changing.
48 If \translator Staff = bass, then look for Staff = *
50 while (current && current->type_str_ != to_type)
52 last = current;
53 current = current->daddy_trans_l_;
57 if (current)
58 if (last)
60 Translator_group * dest =
61 report_to_l ()->find_create_translator_l (to_type, to_id);
62 current->remove_translator_p (last);
63 dest->add (last);
65 else
69 We could change the current translator's id, but that would make
70 errors hard to catch
72 last->translator_id_str_ = change_l_->change_to_id_str_;
74 error ("I'm one myself");
76 else
77 error ("None of these in my family.");
78 Music_iterator::process_and_next (m);
81 IMPLEMENT_IS_TYPE_B1 (Change_iterator, Music_iterator);