]> git.donarmstrong.com Git - lilypond.git/blob - lily/request-chord-iterator.cc
release: 1.3.86
[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
16
17 void
18 Request_chord_iterator::construct_children()
19 {
20   elt_length_mom_ =elt_l ()->length_mom ();
21   get_req_translator_l();
22 }
23
24 Request_chord*
25 Request_chord_iterator::elt_l () const
26 {
27   return (Request_chord*) music_l_;
28 }
29
30 Request_chord_iterator::Request_chord_iterator ()
31 {
32   last_b_ = false;
33 }
34
35
36 bool
37 Request_chord_iterator::ok() const
38 {
39   return (elt_length_mom_ && !last_b_) || first_b_;
40 }
41
42 Moment
43 Request_chord_iterator::next_moment() const
44 {
45   Moment m (0);
46   if  (!first_b_)
47     m = elt_length_mom_;
48   return m;
49 }
50
51
52 void
53 Request_chord_iterator::do_print() const
54 {
55 #ifndef NPRINT
56   DEBUG_OUT << "duration: " << elt_length_mom_;
57 #endif
58 }
59
60 void
61 Request_chord_iterator::do_process_and_next (Moment mom)
62 {
63   if (first_b_)
64     {
65       for (SCM s = dynamic_cast<Music_sequence *> (music_l_)->music_list (); gh_pair_p (s);  s = gh_cdr (s))
66         {
67           Music *mus = unsmob_music (gh_car (s));
68           if (Request * req_l = dynamic_cast<Request*> (mus))
69             {
70               bool gotcha = try_music (req_l);
71               if (!gotcha)
72                 req_l->origin ()->warning (_f ("Junking request: `%s'", classname( req_l)));
73             }
74           else
75             mus->origin ()->warning (_f ("Huh?  Not a Request: `%s'",
76                                                  classname (mus)));
77                     }
78       first_b_ = false;
79     }
80
81   if (mom >= elt_length_mom_)
82     last_b_ = true;
83 }