]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/folded-repeat-iterator.cc
release: 1.5.29
[lilypond.git] / lily / folded-repeat-iterator.cc
index 1083b8fa692cbb1f29c8e5e69324d5b601aae628..ec30d1b5485030e0e96875183893146859f3ebe9 100644 (file)
@@ -3,10 +3,16 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
+
+/*
+   Folded repeats are a stupid idea at this point, so we refrain from
+   implementing get_music () and skip ().
+*/
+
 #include "folded-repeat-iterator.hh"
 #include "repeated-music.hh"
 #include "music-list.hh"
@@ -31,42 +37,50 @@ Folded_repeat_iterator::~Folded_repeat_iterator ()
   delete alternative_iter_p_;
 }
 
+Folded_repeat_iterator::Folded_repeat_iterator (Folded_repeat_iterator const &src)
+  : Music_iterator (src)
+{
+  main_iter_p_ = src.main_iter_p_ ? src.main_iter_p_->clone () : 0;
+  alternative_iter_p_ = src.alternative_iter_p_ ? src.alternative_iter_p_->clone () : 0;
+  main_length_mom_ = src.main_length_mom_;
+}
+
 Moment
-Folded_repeat_iterator::next_moment () const
+Folded_repeat_iterator::pending_moment () const
 {
   if (main_iter_p_)
     {
-      return main_iter_p_->next_moment ();
+      return main_iter_p_->pending_moment ();
     }
   else
-    return main_length_mom_ + alternative_iter_p_->next_moment ();
+    return main_length_mom_ + alternative_iter_p_->pending_moment ();
 }
 
 void
 Folded_repeat_iterator::construct_children ()
 {
-  Repeated_music const *  mus = dynamic_cast<Repeated_music const*> (music_l_);
-  main_iter_p_ = get_iterator_p (mus->repeat_body_p_);
-  if (!main_iter_p_->ok())
+  Repeated_music  *  mus = dynamic_cast<Repeated_music*> (music_l ());
+  main_iter_p_ = get_iterator_p (mus->body ());
+  if (!main_iter_p_->ok ())
     {
-      leave_body ();
+     leave_body ();
       enter_alternative ();
     }
 }
 
 void
-Folded_repeat_iterator::do_process_and_next (Moment m)
+Folded_repeat_iterator::process (Moment m)
 {
-  if (!m)
+  if (!m.to_bool () )
     {
-      bool success = try_music (music_l_);
+      bool success = try_music (music_l ());
       if (!success)
-       music_l_->warning ( _("no one to print a repeat brace"));
+       music_l ()->origin ()->warning (_ ("no one to print a repeat brace"));
     }
   
   if (main_iter_p_)
     {
-      main_iter_p_->process_and_next (m);
+      main_iter_p_->process (m);
       if (!main_iter_p_->ok ())
        leave_body ();
     }
@@ -78,7 +92,7 @@ Folded_repeat_iterator::do_process_and_next (Moment m)
   
   if (alternative_iter_p_)
     {
-      alternative_iter_p_->process_and_next (m - main_length_mom_);
+      alternative_iter_p_->process (m - main_length_mom_);
       if (!alternative_iter_p_->ok ())
        {
          delete alternative_iter_p_;
@@ -90,36 +104,30 @@ Folded_repeat_iterator::do_process_and_next (Moment m)
 void
 Folded_repeat_iterator::leave_body ()
 {
-  Repeated_music const *  mus = dynamic_cast<Repeated_music const*> (music_l_);
+  Repeated_music *  mus = dynamic_cast<Repeated_music *> (music_l ());
   delete main_iter_p_;
   main_iter_p_ = 0;
-  main_length_mom_ +=  mus->repeat_body_p_->length_mom ();
+  main_length_mom_ +=  mus->body ()->length_mom ();
 }
 
 void
 Folded_repeat_iterator::enter_alternative ()
 {
-  Repeated_music const *  mus = dynamic_cast<Repeated_music const*> (music_l_);  
-  if (mus->alternatives_p_)
+  Repeated_music *  mus = dynamic_cast<Repeated_music *> (music_l ());  
+  if (mus->alternatives ())
     {
       Simultaneous_music_iterator * s = new Simultaneous_music_iterator;
       s->separate_contexts_b_ = true;
-      s->init_translator (mus->alternatives_p_, report_to_l ());
-  
+      s->init_translator (mus, report_to_l ());
+      
       alternative_iter_p_ = s;
       alternative_iter_p_->construct_children ();
     }
 }
 
-void
-Folded_repeat_iterator::do_print () const
-{
-#ifndef NPRINT
-#endif
-}
 
 Music_iterator*
-Folded_repeat_iterator::try_music_in_children (Music const* m) const
+Folded_repeat_iterator::try_music_in_children (Music * m) const
 {
   if (main_iter_p_)
     {
@@ -129,3 +137,5 @@ Folded_repeat_iterator::try_music_in_children (Music const* m) const
     return alternative_iter_p_->try_music (m);
   return 0;
 }
+
+IMPLEMENT_CTOR_CALLBACK (Folded_repeat_iterator);