LSR: Update.
[lilypond/mpolesky.git] / lily / bar-check-iterator.cc
blob1fbd7905cccf00e9781dfbe702c4c4a74882c763
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2001--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "context.hh"
21 #include "input.hh"
22 #include "international.hh"
23 #include "music.hh"
24 #include "simple-music-iterator.hh"
27 Check bar checks. We do this outside the engravers so that you can
28 race through the score using skipTypesetting to correct durations.
30 class Bar_check_iterator : Simple_music_iterator
32 public:
33 virtual void process (Moment);
34 Bar_check_iterator ();
35 DECLARE_SCHEME_CALLBACK (constructor, ());
38 IMPLEMENT_CTOR_CALLBACK (Bar_check_iterator);
40 Bar_check_iterator::Bar_check_iterator ()
44 void
45 Bar_check_iterator::process (Moment m)
47 Simple_music_iterator::process (m);
48 if (!m.to_bool ())
50 Context *tr = get_outlet ();
52 SCM check = tr->get_property ("ignoreBarChecks");
53 if (to_boolean (check))
54 return;
56 SCM mp = tr->get_property ("measurePosition");
57 SCM sync = tr->get_property ("barCheckSynchronize");
59 Moment *where = unsmob_moment (mp);
60 if (!where)
61 return;
63 if (where->main_part_)
65 bool warn = true;
66 if (to_boolean (sync))
68 SCM mp;
69 tr = tr->where_defined (ly_symbol2scm ("measurePosition"), &mp);
70 Moment zero;
71 tr->set_property ("measurePosition", zero.smobbed_copy ());
73 else
75 SCM lf = tr->get_property ("barCheckLastFail");
76 if (unsmob_moment (lf)
77 && *unsmob_moment (lf) == *where)
78 warn = false;
79 else
80 tr->set_property ("barCheckLastFail", mp);
83 if (warn)
84 get_music ()->origin ()->warning (_f ("barcheck failed at: %s",
85 where->to_string ()));