]> git.donarmstrong.com Git - lilypond.git/blob - lily/chord-tremolo-iterator.cc
2002-07-17 Han-Wen <hanwen@cs.uu.nl>
[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--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10
11 /*
12   this is culled from various other iterators, but sharing code by
13   subclassing proved to be too difficult.
14  */
15
16 #include "input.hh"
17 #include "chord-tremolo-iterator.hh"
18 #include "repeated-music.hh"
19
20 void
21 Chord_tremolo_iterator::construct_children ()
22 {
23   Repeated_music * rep = dynamic_cast<Repeated_music*> (music_l ());
24   factor_  = Moment (Rational(1, 1));
25   child_iter_p_ = get_iterator_p (rep->body ());
26 }
27
28 Chord_tremolo_iterator::Chord_tremolo_iterator ()
29 {
30   factor_ = 1;
31   child_iter_p_ = 0;
32 }
33
34 Chord_tremolo_iterator::Chord_tremolo_iterator (Chord_tremolo_iterator const &src)
35   : Music_iterator (src)
36 {
37   factor_ = src.factor_;
38   child_iter_p_ = src.child_iter_p_ ? src.child_iter_p_->clone () : 0; 
39 }
40
41 void
42 Chord_tremolo_iterator::process (Moment m)
43 {
44   if (!m.to_bool () )
45     {
46       Music_iterator *yeah = try_music (music_l ());
47       if (yeah)
48         set_translator (yeah->report_to_l ());
49       else
50         music_l ()->origin ()->warning (_ ("no one to print a tremolos"));
51     }
52
53   child_iter_p_->process (factor_ * m);
54 }
55
56 Moment
57 Chord_tremolo_iterator::pending_moment () const
58 {
59   return child_iter_p_->pending_moment () / factor_;
60 }
61
62 bool
63 Chord_tremolo_iterator::ok () const
64 {
65   return child_iter_p_ && child_iter_p_->ok ();
66 }
67
68 Chord_tremolo_iterator::~Chord_tremolo_iterator ()
69 {
70   delete child_iter_p_;
71 }
72
73 Music_iterator*
74 Chord_tremolo_iterator::try_music_in_children (Music  *m) const
75 {
76   return child_iter_p_->try_music (m);
77 }
78
79
80
81 IMPLEMENT_CTOR_CALLBACK (Chord_tremolo_iterator);
82