-/*
- auto-change-iterator.cc -- implement Auto_change_iterator
+/*
+ This file is part of LilyPond, the GNU music typesetter.
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ Copyright (C) 1999--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
-#include "auto-change-music.hh"
-#include "auto-change-iterator.hh"
-#include "translator-group.hh"
-#include "musical-request.hh"
+ LilyPond is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ LilyPond is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
+*/
-void
-Auto_change_iterator::change_to (Music_iterator *it, String to_type,
- String to_id)
-{
- Translator_group * current = it->report_to_l ();
- Translator_group * last = 0;
-
- /*
- Cut & Paste from Change_iterator (ugh).
-
- TODO: abstract this function
- */
-
- /* find the type of translator that we're changing.
-
- If \translator Staff = bass, then look for Staff = *
- */
- while (current && current->type_str_ != to_type)
- {
- last = current;
- current = current->daddy_trans_l_;
- }
+#include "change-iterator.hh"
+#include "change-sequence-iterator.hh"
- if (current && current->id_str_ == to_id)
- {
- String msg;
- msg += _ ("Can't switch translators, I'm there already");
- }
-
- if (current)
- if (last)
- {
- Translator_group * dest =
- it->report_to_l ()->find_create_translator_l (to_type, to_id);
- current->remove_translator_p (last);
- dest->add_group_translator (last);
- }
- else
- {
- /*
- We could change the current translator's id, but that would make
- errors hard to catch
-
- last->translator_id_str_ = change_l ()->change_to_id_str_;
- */
- // error (_ ("I'm one myself"));
- }
- else
- ; // error (_ ("none of these in my family"));
-
-}
+class Auto_change_iterator : public Change_sequence_iterator
+{
+public:
+ DECLARE_SCHEME_CALLBACK (constructor, ());
+ Auto_change_iterator () {}
-Pitch_interrogate_req* spanish_inquisition; // nobody expects it
+private:
+ virtual void change_to (const string &id);
+};
void
-Auto_change_iterator::do_process (Moment m)
+Auto_change_iterator::change_to (const string &id)
{
- Music_wrapper_iterator::do_process (m);
-
- if (!spanish_inquisition)
- spanish_inquisition = new Pitch_interrogate_req;
-
- Music_iterator *it = try_music (spanish_inquisition);
-
- if (it && spanish_inquisition->pitch_arr_.size ())
- {
- Musical_pitch p = spanish_inquisition->pitch_arr_[0];
- Direction s = Direction (sign(p.steps ()));
- if (s != where_dir_)
- {
- where_dir_ = s;
- String to_id = (s >= 0) ? "up" : "down";
- Auto_change_music const * auto_mus = dynamic_cast<Auto_change_music const* > (music_l_);
-
- change_to (it, auto_mus->what_str_, to_id);
- }
- }
-
- spanish_inquisition->pitch_arr_.clear ();
+ // N.B. change_to() returns an error message. Silence is the legacy
+ // behavior here, but maybe that should be changed.
+ Change_iterator::change_to (*child_iter_, ly_symbol2scm ("Staff"), id);
}
-Auto_change_iterator::Auto_change_iterator( )
-{
- where_dir_ = CENTER;
-}
+IMPLEMENT_CTOR_CALLBACK (Auto_change_iterator);