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