]> git.donarmstrong.com Git - lilypond.git/blob - lily/request-iterator.cc
release: 1.1.1
[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   elt_duration_ =elt_l ()->duration ();
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_duration_ && !last_b_) || first_b_;
40 }
41
42
43
44 Moment
45 Request_chord_iterator::next_moment() const
46 {
47   Moment m (0);
48   if  (!first_b_)
49     m = elt_duration_;
50   return m;
51 }
52
53 void
54 Request_chord_iterator::do_print() const
55 {
56 #ifndef NPRINT
57   DOUT << "duration: " << elt_duration_;
58 #endif
59 }
60
61 void
62 Request_chord_iterator::do_process_and_next (Moment mom)
63 {
64   if (first_b_)
65     {
66       for (PCursor<Music*> i (elt_l ()->music_p_list_p_->top ()); i.ok(); i++)
67         {
68           if (Request * req_l = dynamic_cast<Request*> (i.ptr()))
69             {
70               bool gotcha = report_to_l()->try_request (req_l);
71               if (!gotcha)
72                 req_l->warning (_f ("junking request: `%s\'", req_l->name()));
73             }
74           else
75             i.ptr ()->warning (_f ("Huh? Not a Request: `%s\'", i.ptr()->name ()));
76         }
77       first_b_ = false;
78     }
79
80   if (mom >= elt_duration_)
81     last_b_ = true;
82 }