]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/folded-repeat-iterator.cc
patch::: 1.5.4.jcn4
[lilypond.git] / lily / folded-repeat-iterator.cc
index ddc6e68839099eaf68e7e3d53e91c1032d4468b6..18cfe09204d44fdd842efaea557dbd81ddfe5499 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
@@ -37,6 +37,14 @@ 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::pending_moment () const
 {
@@ -51,11 +59,11 @@ Folded_repeat_iterator::pending_moment () const
 void
 Folded_repeat_iterator::construct_children ()
 {
-  Repeated_music  *  mus = dynamic_cast<Repeated_music*> (music_l_);
+  Repeated_music  *  mus = dynamic_cast<Repeated_music*> (music_l ());
   main_iter_p_ = get_iterator_p (mus->body ());
-  if (!main_iter_p_->ok())
+  if (!main_iter_p_->ok ())
     {
-      leave_body ();
+     leave_body ();
       enter_alternative ();
     }
 }
@@ -63,11 +71,11 @@ Folded_repeat_iterator::construct_children ()
 void
 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_->origin ()->warning ( _("no one to print a repeat brace"));
+       music_l ()->origin ()->warning (_ ("no one to print a repeat brace"));
     }
   
   if (main_iter_p_)
@@ -96,7 +104,7 @@ Folded_repeat_iterator::process (Moment m)
 void
 Folded_repeat_iterator::leave_body ()
 {
-  Repeated_music *  mus = dynamic_cast<Repeated_music *> (music_l_);
+  Repeated_music *  mus = dynamic_cast<Repeated_music *> (music_l ());
   delete main_iter_p_;
   main_iter_p_ = 0;
   main_length_mom_ +=  mus->body ()->length_mom ();
@@ -105,7 +113,7 @@ Folded_repeat_iterator::leave_body ()
 void
 Folded_repeat_iterator::enter_alternative ()
 {
-  Repeated_music *  mus = dynamic_cast<Repeated_music *> (music_l_);  
+  Repeated_music *  mus = dynamic_cast<Repeated_music *> (music_l ());  
   if (mus->alternatives ())
     {
       Simultaneous_music_iterator * s = new Simultaneous_music_iterator;
@@ -129,3 +137,5 @@ Folded_repeat_iterator::try_music_in_children (Music * m) const
     return alternative_iter_p_->try_music (m);
   return 0;
 }
+
+IMPLEMENT_CTOR_CALLBACK (Folded_repeat_iterator);