2 repeated-music-iterator.cc -- implement Repeated_music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "repeated-music-iterator.hh"
11 #include "repeated-music.hh"
12 #include "musical-request.hh"
13 #include "translator-group.hh"
14 #include "command-request.hh"
16 Repeated_music_iterator::Repeated_music_iterator ()
19 alternative_iter_p_ = 0;
22 Repeated_music_iterator::~Repeated_music_iterator ()
24 delete repeat_iter_p_;
25 delete alternative_iter_p_;
29 Repeated_music_iterator::do_print () const
31 if (repeat_iter_p_) repeat_iter_p_->print ();
32 if (alternative_iter_p_) alternative_iter_p_->print ();
36 Repeated_music_iterator::construct_children ()
38 repeat_iter_p_ = get_iterator_p (repeated_music_l ()->repeat_p_);
42 Repeated_music_iterator::do_process_and_next (Moment m)
46 bool success = report_to_l ()->try_music (repeated_music_l ());
48 music_l_->warning ( _("No one to print a volta bracket"));
50 if (repeat_iter_p_ && repeat_iter_p_->ok ())
51 repeat_iter_p_->process_and_next (m);
53 alternative_iter_p_->process_and_next (m -
54 repeated_music_l ()->repeat_p_->duration ());
55 Music_iterator::do_process_and_next (m);
59 Repeated_music_iterator::next_moment () const
62 return repeat_iter_p_->next_moment ();
63 else if (alternative_iter_p_)
64 // return alternative_iter_p_->next_moment ();
65 return alternative_iter_p_->next_moment () +
66 repeated_music_l ()->repeat_p_->duration ();
68 return repeated_music_l ()->repeat_p_->duration ();
72 Repeated_music_iterator::ok () const
76 return repeat_iter_p_->ok ();
77 else if (alternative_iter_p_)
78 return alternative_iter_p_->ok ();
81 if (repeat_iter_p_ && repeat_iter_p_->ok ())
83 else if (!alternative_iter_p_)
85 return alternative_iter_p_->ok ();
86 #else // perhaps iterating stops because we return false on repeat_iter...
89 if (repeat_iter_p_->ok ())
94 Repeated_music_iterator *urg = (Repeated_music_iterator*)this;
95 delete urg->repeat_iter_p_;
96 urg->repeat_iter_p_ = 0;
97 urg->alternative_iter_p_ = dynamic_cast<Music_list_iterator*>
98 (get_iterator_p ((Music*)repeated_music_l ()->alternative_p_));
101 if (alternative_iter_p_)
102 return alternative_iter_p_->ok ();
108 Repeated_music_iterator::repeated_music_l () const
110 return (Repeated_music*)Music_iterator::music_l_;