]> git.donarmstrong.com Git - lilypond.git/blob - lily/request-iterator.cc
release: 0.1.11
[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 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "translator.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 void
57 Request_chord_iterator::process_and_next (Moment mom)
58 {
59   if (first_b_) 
60     {
61       for (PCursor<Music*> i (elt_l_->music_p_list_); i.ok(); i++) 
62         {
63           assert (i->is_type_b (Request::static_name()));
64           Request * req_l = (Request*)i.ptr();
65           bool gotcha = report_to_l()->try_request (req_l);
66           if (!gotcha)
67             req_l->warning ("Junking request: " + String (req_l->name()));
68
69         }
70       first_b_ = false;
71     }
72
73   if (mom >= elt_duration_)
74     last_b_ = true;  
75 }