]> git.donarmstrong.com Git - lilypond.git/blob - lily/request-iterator.cc
81b7fd26865d6cb25759dbd5e5604c8f69d40159
[lilypond.git] / lily / request-iterator.cc
1 /*
2   request-iterator.cc -- implement Request_chord_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "translator-group.hh"
10 #include "debug.hh"
11 #include "request-iterator.hh"
12 #include "music-list.hh"
13 #include "request.hh"
14
15 IMPLEMENT_IS_TYPE_B1(Request_chord_iterator,Music_iterator);
16
17 void
18 Request_chord_iterator::construct_children()
19 {
20   get_req_translator_l();
21 }
22
23 Request_chord_iterator::Request_chord_iterator (Request_chord*el_l)
24 {
25   elt_l_ = el_l;
26   MInterval elt_dur =el_l->time_int();
27   elt_duration_ = elt_dur.length ();
28   last_b_ = false;
29 }
30
31
32 bool
33 Request_chord_iterator::ok() const
34 {
35   return (elt_duration_ && !last_b_) || first_b_;
36 }
37
38
39
40 Moment
41 Request_chord_iterator::next_moment() const
42 {
43   Moment m (0);
44   if  (!first_b_)
45     m = elt_duration_;
46   return m;
47 }
48
49 void
50 Request_chord_iterator::do_print() const
51 {
52 #ifndef NPRINT
53   DOUT << "duration: " << elt_duration_;
54 #endif
55 }
56
57 void
58 Request_chord_iterator::process_and_next (Moment mom)
59 {
60   if (first_b_)
61     {
62       for (PCursor<Music*> i (elt_l_->music_p_list_); i.ok(); i++)
63         {
64           assert (i->is_type_b (Request::static_name()));
65           Request * req_l = (Request*)i.ptr();
66           bool gotcha = report_to_l()->try_request (req_l);
67           if (!gotcha)
68             req_l->warning (_f ("junking request: `%s\'", req_l->name()));
69         }
70       first_b_ = false;
71     }
72
73   if (mom >= elt_duration_)
74     last_b_ = true;
75 }