]> git.donarmstrong.com Git - lilypond.git/blob - lily/request-chord-iterator.cc
aaeeeecac7bcb5427fad13d5c56aa341d839d8e3
[lilypond.git] / lily / request-chord-iterator.cc
1 /*
2   request-chord-iterator.cc -- implement Request_chord_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "translator-group.hh"
10 #include "debug.hh"
11 #include "request-chord-iterator.hh"
12 #include "music-list.hh"
13 #include "request.hh"
14
15 Request_chord_iterator::Request_chord_iterator ()
16 {
17 }
18
19 Request_chord_iterator::Request_chord_iterator (Request_chord_iterator const &src)
20   : Simple_music_iterator (src)
21 {
22 }
23
24 Translator_group*
25 Request_chord_iterator::get_req_translator_l ()
26 {
27   assert (report_to_l ());
28   if (report_to_l ()->is_bottom_translator_b ())
29     return report_to_l ();
30
31   set_translator (report_to_l ()->get_default_interpreter ());
32   return report_to_l ();
33 }
34
35 void
36 Request_chord_iterator::construct_children()
37 {
38   Simple_music_iterator::construct_children ();
39   get_req_translator_l();
40 }
41
42 Request_chord*
43 Request_chord_iterator::elt_l () const
44 {
45   return (Request_chord*) music_l_;
46 }
47
48 SCM
49 Request_chord_iterator::get_music (Moment) const
50 {
51   SCM s = SCM_EOL;
52   if (last_processed_mom_ < Moment (0))
53     {
54       Music_sequence * ms = dynamic_cast<Music_sequence*> (music_l_);
55      
56       for (SCM m = ms->music_list (); gh_pair_p (m); m = gh_cdr (m))
57         {
58           s = gh_cons (gh_car (m) , s);
59         }
60     }
61   return s;
62 }
63
64 void
65 Request_chord_iterator::process (Moment m)
66 {
67   if (last_processed_mom_ < Moment (0))
68     {
69       for (SCM s = dynamic_cast<Music_sequence *> (music_l_)->music_list ();
70            gh_pair_p (s);  s = gh_cdr (s))
71         {
72           Music *mus = unsmob_music (gh_car (s));
73
74           if (Request * req_l = dynamic_cast<Request*> (mus))
75             {
76               bool gotcha = try_music (req_l);
77               if (!gotcha)
78                 req_l->origin ()->warning (_f ("Junking request: `%s'", classname( req_l)));
79             }
80           else
81             mus->origin ()->warning (_f ("Huh?  Not a Request: `%s'",
82                                          classname (mus)));
83         }
84     }
85   skip (m);
86 }