lilypond-1.3.28
[lilypond.git] / lily / request-chord-iterator.cc
blob65f3027077905d8787dea11b8b4e116de90866ba
1 /*
2 request-chord-iterator.cc -- implement Request_chord_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "translator-group.hh"
10 #include "debug.hh"
11 #include "request-chord-iterator.hh"
12 #include "music-list.hh"
13 #include "request.hh"
17 void
18 Request_chord_iterator::construct_children()
20 elt_length_mom_ =elt_l ()->length_mom ();
21 get_req_translator_l();
24 Request_chord*
25 Request_chord_iterator::elt_l () const
27 return (Request_chord*) music_l_;
30 Request_chord_iterator::Request_chord_iterator ()
32 last_b_ = false;
33 cursor_ = 0;
37 bool
38 Request_chord_iterator::ok() const
40 return (elt_length_mom_ && !last_b_) || first_b_;
43 Moment
44 Request_chord_iterator::next_moment() const
46 Moment m (0);
47 if (!first_b_)
48 m = elt_length_mom_;
49 return m;
53 void
54 Request_chord_iterator::do_print() const
56 #ifndef NPRINT
57 DEBUG_OUT << "duration: " << elt_length_mom_;
58 #endif
61 void
62 Request_chord_iterator::do_process_and_next (Moment mom)
64 if (first_b_)
66 for (Cons<Music> *i = elt_l ()->music_p_list_p_->head_; i; i = i->next_)
68 if (Request * req_l = dynamic_cast<Request*> (i->car_))
70 bool gotcha = try_music (req_l);
71 if (!gotcha)
72 req_l->warning (_f ("Junking request: `%s'", classname( req_l)));
74 else
75 i->car_->warning (_f ("Huh? Not a Request: `%s'",
76 classname (i->car_)));
78 first_b_ = false;
81 if (mom >= elt_length_mom_)
82 last_b_ = true;