]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/music-iterator.cc
release: 1.1.43
[lilypond.git] / lily / music-iterator.cc
index 43891b05605675e9025f0ecc810b6a7e943e9a10..bcb465f22b1c49d598a14dc99afdc0eed833d470 100644 (file)
@@ -3,33 +3,31 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include "debug.hh"
 #include "music-list.hh"
 #include "music-iterator.hh"
-#include "voice-iterator.hh"
 #include "property-iterator.hh"
-#include "chord-iterator.hh"
 #include "request-iterator.hh"
+#include "sequential-music-iterator.hh"
+#include "simultaneous-music-iterator.hh"
 #include "translator-group.hh"
 #include "translation-property.hh"
 #include "change-iterator.hh"
 #include "change-translator.hh"
 #include "music-wrapper.hh"
 #include "music-wrapper-iterator.hh"
-#include "compressed-music-iterator.hh"
-#include "compressed-music.hh"
-
-
-
-
-
+#include "time-scaled-music-iterator.hh"
+#include "time-scaled-music.hh"
+#include "context-specced-music.hh"
+#include "new-repeated-music.hh"
+#include "folded-repeat-iterator.hh"
+#include "unfolded-repeat-iterator.hh"
 
 void
 Music_iterator::do_print() const
 {
-
 }
 
 void
@@ -61,50 +59,27 @@ Music_iterator::get_req_translator_l()
   return report_to_l();
 }
 
-void
-Music_iterator::push_translator (Translator_group*t)
-{
-  report_to_l_arr_.push (t);
-  t->iterator_count_ ++;
-}
-
-void
-Music_iterator::pop_translator()
-{
-  report_to_l()->iterator_count_ --;
-  assert (report_to_l()->iterator_count_ >=0);
-  report_to_l_arr_.pop();
-}
 
 Translator_group* 
 Music_iterator::report_to_l() const
 {
-  if (! report_to_l_arr_.size())
-    return 0;
-  return report_to_l_arr_.top();
+  return handle_.report_to_l ();
 }
 
 
 void
 Music_iterator::set_translator (Translator_group*trans)
-{   
-  if (report_to_l()==trans)
-    return;
-  if (report_to_l())
-    pop_translator();
-  if (trans)
-    push_translator (trans);
+{
+  handle_.set_translator (trans);
 }
 
 void
 Music_iterator::construct_children()
 {
-
 }
 
 Music_iterator::~Music_iterator()
 {
-  set_translator (0);
 }
 
 Moment
@@ -133,9 +108,10 @@ Music_iterator::ok() const
 }
 
 Music_iterator*
-Music_iterator::static_get_iterator_p (Music const *m, Translator_group *report_l)
+Music_iterator::static_get_iterator_p (Music const *m)
 {
   Music_iterator * p =0;
+  
   if (dynamic_cast<Request_chord  const *> (m))
     p = new Request_chord_iterator;
   else if (dynamic_cast<Simultaneous_music  const *> (m)) 
@@ -146,36 +122,49 @@ Music_iterator::static_get_iterator_p (Music const *m, Translator_group *report_
     p = new Property_iterator;
   else if (dynamic_cast<Change_translator  const *> (m))
     p = new Change_iterator;
-  else if (dynamic_cast<Compressed_music  const *> (m))
-    p = new Compressed_music_iterator;
+  else if (dynamic_cast<Time_scaled_music  const *> (m))
+    p = new Time_scaled_music_iterator;
   else if (dynamic_cast<Music_wrapper  const *> (m))
     p = new Music_wrapper_iterator;
-
-  p->music_l_ = m;
-  if (m->translator_type_str_.length_i ())
+  else if (New_repeated_music const * n = dynamic_cast<New_repeated_music const *> (m))
     {
-      Translator_group* a =report_l->
-       find_create_translator_l (m->translator_type_str_, m->translator_id_str_);
-      p->set_translator (a);
+      if (n->fold_b_)
+       p = new Folded_repeat_iterator;
+      else
+       p = new Unfolded_repeat_iterator;
     }
+  else
+    assert (0);
 
-  if (! p->report_to_l())
-    p ->set_translator (report_l);
 
-  
+  p->music_l_ = m;
   return p;
 }
 
 void
-Music_iterator::inherit_info(Music_iterator const *)
+Music_iterator::init_translator (Music const *m, Translator_group  *report_l)
 {
+  music_l_ = m;
+  if (Context_specced_music const * csm =dynamic_cast<Context_specced_music const*>(m))
+    {
+      Translator_group* a =report_l->
+       find_create_translator_l (csm->translator_type_str_, csm->translator_id_str_);
+
+      set_translator (a);
+      
+    }
+
+  if (! report_to_l())
+    set_translator (report_l);
 }
 
+
 Music_iterator*
 Music_iterator::get_iterator_p (Music const*m) const
 {
-  Music_iterator*p = static_get_iterator_p (m, report_to_l());
-  p->inherit_info (this);
+  Music_iterator*p = static_get_iterator_p (m);
+  p->init_translator (m, report_to_l());
+  
   p->construct_children();
   return p;
 }