source file of the GNU LilyPond music typesetter
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "translator-group.hh"
-#include "debug.hh"
+#include "warn.hh"
#include "sequential-music-iterator.hh"
#include "music-list.hh"
+/*
+ move to context of child iterator if it is deeper down in the
+ hierarchy.
+ */
void
-Sequential_music_iterator::do_print() const
+Sequential_music_iterator::descend_to_child ()
{
- if (iter_p_)
- iter_p_->print();
-}
-
-Sequential_music_iterator::Sequential_music_iterator ()
-{
- cursor_ = 0;
- here_mom_ = 0;
- iter_p_ =0;
-}
+ Translator_group * child_report = child_report = iter_->report_to ();
+ Translator_group * me_report = report_to ();
-void
-Sequential_music_iterator::construct_children()
-{
- cursor_ = dynamic_cast<Sequential_music const*> (music_l_)->music_p_list_p_->head_;
-
- while (cursor_)
+ Translator_group * c = child_report;
+ while (c && c != me_report)
{
- start_next_element();
- if (!iter_p_->ok())
- {
- leave_element();
- }
- else
- {
- set_Sequential_music_translator();
- break;
- }
+ c= c->daddy_trans_;
}
+
+ if (c == me_report)
+ set_translator (child_report);
}
-void
-Sequential_music_iterator::leave_element()
-{
- delete iter_p_;
- iter_p_ =0;
- Moment elt_time = cursor_->car_->length_mom ();
- here_mom_ += elt_time;
- cursor_ =cursor_->next_;
-}
-
-void
-Sequential_music_iterator::start_next_element()
-{
- assert (!iter_p_);
- iter_p_ = get_iterator_p (cursor_->car_);
-}
-
-void
-Sequential_music_iterator::set_Sequential_music_translator()
-{
- if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ())
- set_translator (iter_p_->report_to_l());
-}
-
-Sequential_music_iterator::~Sequential_music_iterator()
-{
- assert (! iter_p_);
-}
-
-
-
-
-void
-Sequential_music_iterator::do_process_and_next (Moment until)
-{
- while (1)
- {
- Moment local_until = until - here_mom_;
- while (iter_p_->ok())
- {
- Moment here = iter_p_->next_moment();
- if (here != local_until)
- goto loopexit;
-
- iter_p_->process_and_next (local_until);
- }
-
- if (!iter_p_->ok())
- {
- leave_element();
-
- if (cursor_)
- {
- start_next_element();
- set_Sequential_music_translator();
- }
- else
- {
- goto loopexit;
- }
- }
- }
-loopexit:
-
- Music_iterator::do_process_and_next (until);
-}
+IMPLEMENT_CTOR_CALLBACK (Sequential_music_iterator);
-Moment
-Sequential_music_iterator::next_moment() const
+SCM
+Sequential_music_iterator::get_music_list()const
{
- return iter_p_->next_moment() + here_mom_;
+ return dynamic_cast<Music_sequence const*> (get_music ())->music_list ();
}
-
-bool
-Sequential_music_iterator::ok() const
-{
- return iter_p_;
-}
-