release commit
[lilypond.git] / lily / bar-check-iterator.cc
blob16b03abf2c9fe43e4e788d9e08f2cdfe855c34b5
1 /*
3 bar-check-iterator.cc -- implement Bar_check_iterator
5 source file of the GNU LilyPond music typesetter
7 (c) 2001--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 */
11 #include "simple-music-iterator.hh"
12 #include "event.hh"
13 #include "translator-group.hh"
16 Check bar checks. We do this outside the engravers so that you can
17 race through the score using skipTypesetting to correct durations.
19 class Bar_check_iterator : Simple_music_iterator
21 public:
22 VIRTUAL_COPY_CONS(Bar_check_iterator);
23 virtual void process (Moment);
24 Bar_check_iterator( );
25 DECLARE_SCHEME_CALLBACK(constructor, ());
28 IMPLEMENT_CTOR_CALLBACK(Bar_check_iterator);
30 Bar_check_iterator::Bar_check_iterator()
34 void
35 Bar_check_iterator::process (Moment m)
37 Simple_music_iterator::process(m);
38 if (!m.to_bool ())
40 Translator_group *tr = report_to ();
42 SCM mp = tr->get_property ("measurePosition");
43 SCM sync= tr->get_property ("barCheckSynchronize");
45 Moment * where =unsmob_moment (mp);
46 if (!where)
47 return;
49 if (where->main_part_)
51 bool warn =true;
52 if (to_boolean (sync))
54 tr = tr->where_defined (ly_symbol2scm("measurePosition"));
55 Moment zero;
56 tr->set_property ("measurePosition", zero.smobbed_copy ());
58 else
60 SCM lf = tr->get_property ("barCheckLastFail");
61 if (unsmob_moment (lf)
62 && *unsmob_moment (lf) == *where)
63 warn = false;
64 else
65 tr->set_property ("barCheckLastFail", mp);
68 if (warn)
69 get_music ()->origin ()->warning (_f ("barcheck failed at: %s",
70 where->to_string ()));