lilypond-0.1.27
[lilypond.git] / lily / request-iterator.cc
blob3d833b94d1d1ab49562da5a7f6ad19c03c35b82e
1 /*
2 request-iterator.cc -- implement Request_chord_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "translator-group.hh"
10 #include "debug.hh"
11 #include "request-iterator.hh"
12 #include "music-list.hh"
13 #include "request.hh"
15 IMPLEMENT_IS_TYPE_B1(Request_chord_iterator,Music_iterator);
17 void
18 Request_chord_iterator::construct_children()
20 get_req_translator_l();
23 Request_chord_iterator::Request_chord_iterator (Request_chord*el_l)
25 elt_l_ = el_l;
26 MInterval elt_dur =el_l->time_int();
27 elt_duration_ = elt_dur.length ();
28 last_b_ = false;
32 bool
33 Request_chord_iterator::ok() const
35 return (elt_duration_ && !last_b_) || first_b_;
40 Moment
41 Request_chord_iterator::next_moment() const
43 Moment m (0);
44 if (!first_b_)
45 m = elt_duration_;
46 return m;
49 void
50 Request_chord_iterator::do_print() const
52 #ifndef NPRINT
53 DOUT << "duration: " << elt_duration_;
54 #endif
56 void
57 Request_chord_iterator::process_and_next (Moment mom)
59 if (first_b_)
61 for (PCursor<Music*> i (elt_l_->music_p_list_); i.ok(); i++)
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()));
70 first_b_ = false;
73 if (mom >= elt_duration_)
74 last_b_ = true;