]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-check-iterator.cc
new file.
[lilypond.git] / lily / bar-check-iterator.cc
1 /*   
2   bar-check-iterator.cc -- implement Bar_check_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2001--2005  Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "simple-music-iterator.hh"
10 #include "event.hh"
11 #include "context.hh"
12
13 /*
14   Check bar checks. We do this outside the engravers so that you can
15   race through the score using skipTypesetting to correct durations.
16  */
17 class Bar_check_iterator : Simple_music_iterator
18 {
19 public:
20   virtual void process (Moment);
21   Bar_check_iterator ( );
22   DECLARE_SCHEME_CALLBACK (constructor, ());
23 };
24
25 IMPLEMENT_CTOR_CALLBACK (Bar_check_iterator);
26
27 Bar_check_iterator::Bar_check_iterator ()
28 {
29 }
30
31 void
32 Bar_check_iterator::process (Moment m)
33 {
34   Simple_music_iterator::process (m);
35   if (!m.to_bool ())
36     {
37       Context *tr = get_outlet ();
38
39       SCM mp = tr->get_property ("measurePosition");
40       SCM sync = tr->get_property ("barCheckSynchronize");
41
42       Moment * where = unsmob_moment (mp);
43       if (!where)
44         return;
45       
46       if (where->main_part_)
47         {
48           bool warn = true;
49           if (to_boolean (sync))
50             {
51               tr = tr->where_defined (ly_symbol2scm ("measurePosition"));
52               Moment zero;
53               tr->set_property ("measurePosition", zero.smobbed_copy ());
54             }
55           else
56             {
57               SCM lf = tr->get_property ("barCheckLastFail");
58               if (unsmob_moment (lf)
59                   && *unsmob_moment (lf) == *where)
60                 warn = false;
61               else
62                 tr->set_property ("barCheckLastFail", mp);
63             }
64
65           if (warn)
66             get_music ()->origin ()->warning (_f ("barcheck failed at: %s", 
67                                               where->to_string ()));
68         }
69     }
70 }