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