*** empty log message ***
[lilypond.git] / lily / percent-repeat-iterator.cc
blob0f40fba6d28eed53efdcd420e28e2da7cfad923d
1 /*
2 percent-repeat-iterator.cc -- implement Percent_repeat_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 2001--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "percent-repeat-iterator.hh"
11 #include "repeated-music.hh"
12 #include "input.hh"
14 IMPLEMENT_CTOR_CALLBACK (Percent_repeat_iterator);
17 Percent_repeat_iterator::Percent_repeat_iterator ()
19 child_iter_ = 0;
22 void
23 Percent_repeat_iterator::do_quit()
25 if (child_iter_)
26 child_iter_->quit();
28 Percent_repeat_iterator::Percent_repeat_iterator (Percent_repeat_iterator const & p)
29 : Music_iterator (p)
31 child_iter_ = 0;
32 finish_mom_ = p.finish_mom_ ;
34 if (p.child_iter_)
36 child_iter_ = p.child_iter_->clone ();
37 scm_gc_unprotect_object (child_iter_->self_scm());
41 bool
42 Percent_repeat_iterator::ok () const
44 return child_iter_;
47 void
48 Percent_repeat_iterator::construct_children ()
50 Repeated_music * mus =dynamic_cast<Repeated_music *> (get_music ());
51 finish_mom_ = mus->get_length ();
52 child_iter_ = unsmob_iterator (get_iterator (mus->body ()));
56 void
57 Percent_repeat_iterator::process (Moment m)
59 if (!m.to_bool ())
61 Music_iterator *yeah = try_music (get_music ());
62 if (yeah)
63 set_translator (yeah->report_to ());
64 else
65 get_music ()->origin ()->warning ( _ ("no one to print a percent"));
68 if (child_iter_->ok ())
69 child_iter_->process (m);
71 if (finish_mom_ <= m )
73 child_iter_->quit();
74 child_iter_ = 0;
78 Moment
79 Percent_repeat_iterator::pending_moment ()const
81 if (child_iter_->ok ())
82 return child_iter_->pending_moment ();
83 else
84 return finish_mom_ ;
87 Music_iterator*
88 Percent_repeat_iterator::try_music_in_children (Music *m) const
90 return child_iter_->try_music (m);
93 void
94 Percent_repeat_iterator::derived_mark()const
96 if (child_iter_)
97 scm_gc_mark (child_iter_->self_scm());