]> git.donarmstrong.com Git - lilypond.git/blob - lily/percent-repeat-iterator.cc
* scm/music-functions.scm (has-request-chord): don't use
[lilypond.git] / lily / percent-repeat-iterator.cc
1 /*   
2   percent-repeat-iterator.cc --  implement Percent_repeat_iterator
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2001--2005  Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "percent-repeat-iterator.hh"
11
12 #include "repeated-music.hh"
13 #include "input.hh"
14
15 IMPLEMENT_CTOR_CALLBACK (Percent_repeat_iterator);
16
17
18 Percent_repeat_iterator::Percent_repeat_iterator ()
19 {
20   child_iter_ = 0;
21 }
22
23 void
24 Percent_repeat_iterator::do_quit ()
25 {
26   if (child_iter_)
27     child_iter_->quit ();
28 }
29
30 bool
31 Percent_repeat_iterator::ok () const
32 {
33   return child_iter_;
34 }
35
36 void
37 Percent_repeat_iterator::construct_children ()
38 {
39   Music *mus = get_music ();
40   finish_mom_ = mus->get_length ();
41   child_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (mus)));
42 }
43
44
45 void
46 Percent_repeat_iterator::process (Moment m)
47 {
48   if (!m.to_bool ())
49     {
50       Music_iterator *yeah = try_music (get_music ());
51       if (yeah)
52         set_context (yeah->get_outlet ());
53       else
54         get_music ()->origin ()->warning ( _ ("no one to print a percent"));
55     }
56   
57   if (child_iter_->ok ())
58     child_iter_->process (m);
59
60   if (finish_mom_ <= m )
61     {
62       child_iter_->quit (); 
63       child_iter_ = 0;
64     }
65 }
66
67 Moment
68 Percent_repeat_iterator::pending_moment ()const
69 {
70   if (child_iter_->ok ())
71     return child_iter_->pending_moment ();
72   else
73     return finish_mom_ ;
74 }
75
76 Music_iterator*
77 Percent_repeat_iterator::try_music_in_children (Music *m) const
78 {
79   return child_iter_->try_music (m);
80 }
81
82 void
83 Percent_repeat_iterator::derived_mark ()const
84 {
85   if (child_iter_)
86     scm_gc_mark (child_iter_->self_scm ());
87 }
88
89 void
90 Percent_repeat_iterator::derived_substitute (Context *f, Context *t )
91 {
92   if (child_iter_)
93     child_iter_->substitute_outlet (f, t);
94 }