]> git.donarmstrong.com Git - lilypond.git/blob - lily/chord-tremolo-iterator.cc
release: 1.3.39
[lilypond.git] / lily / chord-tremolo-iterator.cc
1 /*   
2   chord-tremolo-iterator.cc --  implement Chord_tremolo_iterator
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10
11 /*
12   this is culled from various other iterators, but sharing code by subclassing proved to be too difficult.
13  */
14
15 #include "chord-tremolo-iterator.hh"
16 #include "repeated-music.hh"
17
18 void
19 Chord_tremolo_iterator::construct_children ()
20 {
21   Repeated_music const* rep = dynamic_cast<Repeated_music const*> (music_l_);
22   factor_  = Moment (1, rep->repeats_i_);
23   child_iter_p_ = get_iterator_p (rep->repeat_body_p_);
24 }
25
26 Chord_tremolo_iterator::Chord_tremolo_iterator()
27 {
28   factor_ = 1;
29   child_iter_p_ = 0;
30 }
31
32 void
33 Chord_tremolo_iterator::do_process_and_next (Moment m)
34 {
35   if (!m)
36     {
37       Music_iterator *yeah = try_music (music_l_);
38       if (yeah)
39         set_translator (yeah->report_to_l ());
40       else
41         music_l_->warning ( _("no one to print a tremolos"));
42     }
43
44   child_iter_p_->process_and_next  (factor_ * m);
45 }
46
47
48 Moment
49 Chord_tremolo_iterator::next_moment () const
50 {
51   return child_iter_p_->next_moment () / factor_;
52 }
53
54 bool
55 Chord_tremolo_iterator::ok () const
56 {
57   return child_iter_p_ && child_iter_p_->ok();
58 }
59
60 Chord_tremolo_iterator::~Chord_tremolo_iterator ()
61 {
62   delete child_iter_p_;
63 }
64
65 Music_iterator*
66 Chord_tremolo_iterator::try_music_in_children (Music const *m) const
67 {
68   return child_iter_p_->try_music (m);
69 }
70
71
72 void
73 Chord_tremolo_iterator::do_print () const
74 {
75   child_iter_p_->print  ();
76 }