]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.86.jcn1
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 13 Sep 2000 17:38:47 +0000 (19:38 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 13 Sep 2000 17:38:47 +0000 (19:38 +0200)
1.3.86.jcn1
===========

* Fixed chord iteration.

1.3.85.jcn5
===========

* Modified part-combiner to use new get_music ()/next () music iterator
  functionality.

1.3.85.jcn4
===========

* Added clone () to music iterators, so that we can do next () on a copy.

1.3.85.jcn3
===========

* Added get_music () and next () to music iterators.

30 files changed:
CHANGES
VERSION
lily/include/auto-change-iterator.hh
lily/include/change-iterator.hh
lily/include/chord-tremolo-iterator.hh
lily/include/folded-repeat-iterator.hh
lily/include/grace-iterator.hh
lily/include/interpretation-context-handle.hh
lily/include/lyric-combine-music-iterator.hh
lily/include/music-iterator.hh
lily/include/music-wrapper-iterator.hh
lily/include/part-combine-music-iterator.hh
lily/include/property-iterator.hh
lily/include/request-chord-iterator.hh
lily/include/request-iterator.hh
lily/include/sequential-music-iterator.hh
lily/include/simple-music-iterator.hh [new file with mode: 0644]
lily/include/simultaneous-music-iterator.hh
lily/include/time-scaled-music-iterator.hh
lily/include/unfolded-repeat-iterator.hh
lily/interpretation-context-handle.cc
lily/music-iterator.cc
lily/music-wrapper-iterator.cc
lily/part-combine-music-iterator.cc
lily/request-chord-iterator.cc
lily/request-iterator.cc
lily/sequential-music-iterator.cc
lily/simple-music-iterator.cc [new file with mode: 0644]
lily/simultaneous-music-iterator.cc
lily/translator-group.cc

diff --git a/CHANGES b/CHANGES
index 974339d20fcf6fc7345da2cccf11cd10f32b90ef..aa2080ce3682020c462b39fe7cb94d4340c23f38 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,24 @@
+1.3.86.jcn1
+===========
+
+* Fixed chord iteration.
+
+1.3.85.jcn5
+===========
+
+* Modified part-combiner to use new get_music ()/next () music iterator
+  functionality.
+
+1.3.85.jcn4
+===========
+
+* Added clone () to music iterators, so that we can do next () on a copy.
+
+1.3.85.jcn3
+===========
+
+* Added get_music () and next () to music iterators.
+
 1.3.85.hwn2
 ===========
 
diff --git a/VERSION b/VERSION
index 42a4121ff5e2d5908aa08edccbf16465d71a6702..f8465bf1cd6df2401f106e2403d5fe34cbd0c6e0 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=86
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=jcn1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index ff55700bc10bf1f4530687c2541649c19ce70a38..aa03806c27f5321325bb7b123865e41f96e66a18 100644 (file)
 #include "music-wrapper-iterator.hh"
 #include "direction.hh"
 
-class Auto_change_iterator  : public Music_wrapper_iterator
+class Auto_change_iterator : public Music_wrapper_iterator
 {
-  Direction where_dir_;
+public:
+  VIRTUAL_COPY_CONS (Music_iterator);
+  Auto_change_iterator ();
 
-  void change_to (Music_iterator* , String, String);
 protected:
   virtual void do_process_and_next (Moment);  
-public:
-  Auto_change_iterator ();
+
+private:
+  Direction where_dir_;
+  void change_to (Music_iterator* , String, String);
 };
 
 #endif /* AUTO_CHANGE_ITERATOR_HH */
index 4ab9d99e4a8851199fe51c9dca4a7ca32d8b15b1..a43c4da5f2d1d73d32632820403299c17d8ac1dd 100644 (file)
 
 class Change_iterator : public Music_iterator
 {
-  void  error (String);
-
-protected:
-  virtual void do_process_and_next (Moment);
-
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   /*
     CTOR is public
    */
+
+protected:
+  virtual void do_process_and_next (Moment);
+
+private:
+  void  error (String);
 };
 
 #endif
index 9cd632985da7c724a5cce2adb25f4fe0178db855..6d25034d6d22b74e7c5801d174da5df6972b328e 100644 (file)
 
 class Chord_tremolo_iterator : public Music_iterator
 {
-  Moment factor_;
-  Music_iterator * child_iter_p_;
-
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   Chord_tremolo_iterator ();
 
 protected:
@@ -28,6 +26,10 @@ protected:
   virtual void do_print () const;
   virtual void do_process_and_next (Moment) ;
   virtual Music_iterator *try_music_in_children (Music *) const;
+
+private:
+  Moment factor_;
+  Music_iterator * child_iter_p_;
 };
 
 
index e26bac173e0c862c758540efd04e85e003fe2718..1b36df304ace130b05a3a227518738bffff8bce2 100644 (file)
  */
 class Folded_repeat_iterator : public Music_iterator
 {
-  Music_iterator * main_iter_p_;
-  Music_iterator * alternative_iter_p_;
-  int count_;
-  Moment main_length_mom_;
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   Folded_repeat_iterator ();
   ~Folded_repeat_iterator ();
   
@@ -36,6 +33,12 @@ protected:
   
   virtual void do_process_and_next (Moment);
   virtual Music_iterator *try_music_in_children (Music *) const;
+
+private:
+  Music_iterator * main_iter_p_;
+  Music_iterator * alternative_iter_p_;
+  int count_;
+  Moment main_length_mom_;
 };
 #endif /* FOLDED_REPEAT_ITERATOR_HH */
 
index 9743d7ab901ddd2f5826c101e60ddae5d53c7fe8..c253d078e826d0bcaebe6fa0a7d74047ec86fe78 100644 (file)
@@ -15,6 +15,7 @@
 class Grace_iterator : public Music_wrapper_iterator
 {
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   ~Grace_iterator ();
   virtual void construct_children () ;
   virtual void do_process_and_next (Moment);
index a8adf33cb4a1057bdc405ebf451db43dcef95b98..cb788f124a9c5e833d9e1806e67d2fc1dd0e4f30 100644 (file)
 
 class Interpretation_context_handle
 {
-  Translator_group * report_to_l_;
-  void down ();
-  void up (Translator_group*);
 public:
   ~Interpretation_context_handle ();
   Interpretation_context_handle ();
+  Interpretation_context_handle* clone () const;
   void set_translator (Translator_group*);
   bool try_music (Music *);
   void operator =(Interpretation_context_handle const&);
   Interpretation_context_handle (Interpretation_context_handle const&);
   Translator_group * report_to_l () const;
+
+private:
+  Translator_group * report_to_l_;
+  void down ();
+  void up (Translator_group*);
 };
 
 #endif /* INTERPRETATION_CONTEXT_HANDLE_HH */
index 226499611007851125a2d1a1e224bd1209331c2f..31a47b489655b0a072531619add3994e82eaefdb 100644 (file)
 
 class Lyric_combine_music_iterator : public Music_iterator
 {
-  Music_iterator * music_iter_p_;
-  Music_iterator * lyric_iter_p_;
-  
+public:
+  VIRTUAL_COPY_CONS (Music_iterator);
+  Lyric_combine_music_iterator ();
+
 protected:
   virtual void construct_children ();
   virtual Moment next_moment () const;
@@ -27,8 +28,10 @@ protected:
   virtual bool ok () const;
   virtual void do_print () const;
   virtual ~Lyric_combine_music_iterator ();
-public:
-  Lyric_combine_music_iterator ();
+
+private:
+  Music_iterator * music_iter_p_;
+  Music_iterator * lyric_iter_p_;
 };
 #endif /* LYRIC_COMBINE_MUSIC_ITERATOR_HH */
 
index 561e9c11eba025a2e57110a7b5cdb398854e98c1..87644b494f8fdb225c0b4f8f698982c068984d05 100644 (file)
   The state of an iterator would be the intersection of the particular music 
   construct with one point in musical time.
  */
-class Music_iterator {
-  Interpretation_context_handle handle_;
-
-protected:
-  Music  * music_l_;
-
-  /// ugh. JUNKME
-  bool first_b_;
-
-  /**
-    Do the actual printing.  This should be overriden in derived classes.  It 
-    is called by #print#, in the public interface
-   */
-  virtual void do_print() const;
-    
-  /**
-    Find a bottom notation context to deliver requests to.
-   */
-  virtual Translator_group* get_req_translator_l();
-
-  /**
-    Get an iterator for MUS, inheriting the translation unit from THIS.
-   */
-  Music_iterator* get_iterator_p (Music *mus) const;
-
-  /** Do the actual move.  This should be overriden in derived
-    classes.  It is called by #process_and_next#, the public interface 
-    */
-  virtual void do_process_and_next (Moment until);
-
-
-  virtual Music_iterator* try_music_in_children (Music  *) const;
-  
+class Music_iterator
+{
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
+
+  Music_iterator ();
+  Music_iterator (Music_iterator const&);
+  virtual ~Music_iterator ();
 
   /**
      Do the reporting.  Will try MUSIC_L_ in its own translator first,
@@ -68,7 +42,7 @@ public:
   /**
     The translation unit that we this iterator is reporting  to now.
    */
-  Translator_group*report_to_l() const;
+  Translator_group*report_to_l () const;
 
   void set_translator (Translator_group*);
   
@@ -78,17 +52,15 @@ public:
   static Music_iterator* static_get_iterator_p (Music * mus);
   void init_translator (Music  *, Translator_group *); 
 
-  Music_iterator();
-    
   ///  Find the next interesting point in time.
-  virtual Moment next_moment() const;
+  virtual Moment next_moment () const;
 
 
   ///Are we finished with this piece of music?
-  virtual bool ok() const;
-
-  virtual ~Music_iterator();
+  virtual bool ok () const;
 
+  virtual Music* get_music ();
+  virtual bool next ();
 
   ///Report all musical information that occurs between now and UNTIL
   void process_and_next (Moment until);
@@ -97,8 +69,40 @@ public:
     Construct sub-iterators, and set the translator to 
     report to.
    */
-  virtual void construct_children();
-  void print() const;
+  virtual void construct_children ();
+  void print () const;
+
+protected:
+  Music  * music_l_;
+
+  /// ugh. JUNKME
+  bool first_b_;
+
+  /**
+    Do the actual printing.  This should be overriden in derived classes.  It 
+    is called by #print#, in the public interface
+   */
+  virtual void do_print () const;
+    
+  /**
+    Find a bottom notation context to deliver requests to.
+   */
+  virtual Translator_group* get_req_translator_l ();
+
+  /**
+    Get an iterator for MUS, inheriting the translation unit from THIS.
+   */
+  Music_iterator* get_iterator_p (Music *) const;
+
+  /** Do the actual move.  This should be overriden in derived
+    classes.  It is called by #process_and_next#, the public interface 
+    */
+  virtual void do_process_and_next (Moment until);
+
+  virtual Music_iterator* try_music_in_children (Music *) const;
+  
+private:
+  Interpretation_context_handle handle_;
 };
 
 #endif // MUSIC_ITERATOR_HH
index 8200709e52f4d803b08c4c7d44b69220c85a0296..1d97eb9067f1ea119c21da649651db9e9322f9c1 100644 (file)
 class Music_wrapper_iterator : public Music_iterator
 {
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   Music_wrapper_iterator ();
+  Music_wrapper_iterator (Music_wrapper_iterator const&);
   ~Music_wrapper_iterator ();
 
   virtual void construct_children  () ;
   virtual Moment next_moment () const;
   virtual bool ok () const;
+  virtual Music* get_music ();
+  virtual bool next ();
 
 protected:
   virtual void do_print () const;
index 7b38e0f033a8d936e2b117d1bc67481e91a7e800..d43a00a72daf9d29a95d459242bc27b10e1005a8 100644 (file)
@@ -15,6 +15,7 @@
 class Part_combine_music_iterator : public Music_iterator
 {
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   Part_combine_music_iterator ();
 
 protected:
@@ -32,11 +33,8 @@ private:
 
   Music_iterator * first_iter_p_;
   Music_iterator * second_iter_p_;
-  Moment now_;
   Moment first_until_;
   Moment second_until_;
-
-  bool combined_b_;
 };
 
 #endif /* PART_COMBINE_MUSIC_ITERATOR_HH */
index 7591fce27748d4e7e510af6bf88ec8a510031741..66c7143656c65092f9260591c7efe1b556a24484 100644 (file)
@@ -21,6 +21,7 @@
 class Property_iterator : public Music_iterator
 {
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   // construction  
 protected:
   virtual void do_process_and_next (Moment);
@@ -28,12 +29,16 @@ protected:
 
 class Push_property_iterator : public Music_iterator
 {
+public:
+  VIRTUAL_COPY_CONS (Music_iterator);
 protected:
   virtual void do_process_and_next (Moment);
 };
 
 class Pop_property_iterator : public Music_iterator
 {
+public:
+  VIRTUAL_COPY_CONS (Music_iterator);
 protected:
   virtual void do_process_and_next (Moment);
 };
index bc092479927baf886341bc77d9a2ed54c52cf6b1..a4794f100b02d92f674668406148b605989b6cfc 100644 (file)
@@ -15,7 +15,8 @@
 /**
    Walk through a Request_chord
  */
-class Request_chord_iterator : public Music_iterator {
+class Request_chord_iterator : public Music_iterator
+{
   Request_chord * elt_l () const;
   /**
      cache elt_l ()->length_mom ().
@@ -24,14 +25,17 @@ class Request_chord_iterator : public Music_iterator {
   bool last_b_;
 
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   Request_chord_iterator ();
+  Request_chord_iterator (Request_chord_iterator const&);
   
+  virtual bool next ();
+  virtual bool ok () const;
 
 protected:
   virtual void do_process_and_next (Moment);
   virtual Moment next_moment() const;
   virtual void construct_children();
-  virtual bool ok() const;
   virtual void do_print() const;
 };
 
index ea2b07b026b221caf0579b1a00ac986fb6ca094d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,23 +0,0 @@
-/*   
-  request-iterator.hh -- declare Request_iterator
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-
-#ifndef REQUEST_ITERATOR_HH
-#define REQUEST_ITERATOR_HH
-
-#include "music-iterator.hh"
-
-class Simple_music_iterator : public Music_iterator
-{
-public:
-protected:
-  virtual void do_process_and_next (Moment );
-};
-
-#endif /* REQUEST_ITERATOR_HH */
-
index 79f493fa8724d02ba34321300383245f4e943291..1a2dc730e7221c233a6857a8eb952c6fff75f898 100644 (file)
 class Sequential_music_iterator :  public Music_iterator
 {
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   Sequential_music_iterator ();
+  Sequential_music_iterator (Sequential_music_iterator const&);
   virtual ~Sequential_music_iterator ();
 
   virtual void construct_children ();
   virtual Moment next_moment () const;
   virtual bool ok () const;
+  virtual Music* get_music ();
+  virtual bool next ();
 
 protected:
   virtual void do_print() const;
diff --git a/lily/include/simple-music-iterator.hh b/lily/include/simple-music-iterator.hh
new file mode 100644 (file)
index 0000000..324c9b9
--- /dev/null
@@ -0,0 +1,26 @@
+/*   
+  simple-music-iterator.hh -- declare Simple_music_iterator
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ */
+
+#ifndef SIMPLE_MUSIC_ITERATOR_HH
+#define SIMPLE_MUSIC_ITERATOR_HH
+
+#include "music-iterator.hh"
+
+class Simple_music_iterator : public Music_iterator
+{
+public:
+  VIRTUAL_COPY_CONS (Music_iterator);
+  Simple_music_iterator ();
+  Simple_music_iterator (Simple_music_iterator const &);
+
+protected:
+  virtual void do_process_and_next (Moment );
+};
+
+#endif /* SIMPLE_MUSIC_ITERATOR_HH */
+
index 6c4008a95b619682a50f72b28dab0fde8ba7a28d..26666c339ccf934482c12e2f42e7909518ab3748 100644 (file)
@@ -9,22 +9,27 @@
 
 #ifndef SIMULTANEOUS_MUSIC_ITERATOR_HH
 #define SIMULTANEOUS_MUSIC_ITERATOR_HH
+
 #include "music-iterator.hh"
 #include "cons.hh"
 
 class Simultaneous_music_iterator : public Music_iterator
 {
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
+  Simultaneous_music_iterator ();
+  Simultaneous_music_iterator (Simultaneous_music_iterator const&);
+  virtual ~Simultaneous_music_iterator ();
 
   /// make a new context for every child.
   bool separate_contexts_b_;
-  
-  Simultaneous_music_iterator ();
-  virtual ~Simultaneous_music_iterator ();
+  int cursor_i_;
 
   virtual void construct_children ();
   virtual Moment next_moment () const;
   virtual bool ok () const;
+  virtual bool next ();
+  virtual Music* get_music ();
 
 protected:
   virtual void do_print () const;
index 28ab473db01fd65a2f9514a1c0fa43979e952dfc..abdd2ac6a646923207c9644456b795255fe845f9 100644 (file)
@@ -15,6 +15,7 @@
 class Time_scaled_music_iterator : public Music_wrapper_iterator
 {
 public:  
+  VIRTUAL_COPY_CONS (Music_iterator);
   // construction
 protected:
   virtual void do_process_and_next (Moment);
index 97a649a10a54f3e025050a163f4f4a651061df97..e52361b4737937ce2b68d20be9484d7b063c6531 100644 (file)
@@ -19,6 +19,7 @@
 class Unfolded_repeat_iterator : public Music_iterator
 {
 public:
+  VIRTUAL_COPY_CONS (Music_iterator);
   /**
      How often have we done the body (assuming bodies are interspersed.)?
    */
index b6a403ea2dcd05e64e2324890308993741db2364..e5b056e60180ec94f89f8c7fa8a005d85238dcc2 100644 (file)
 #include "interpretation-context-handle.hh"
 #include "translator-group.hh"
 
+Interpretation_context_handle::Interpretation_context_handle()
+{
+  report_to_l_ =0;
+}
+
+Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
+{
+  report_to_l_ =0;
+  if (s.report_to_l_)
+    up (s.report_to_l_ );
+}
+
+Interpretation_context_handle*
+Interpretation_context_handle::clone () const
+{
+  Interpretation_context_handle* handle = new Interpretation_context_handle;
+  handle->report_to_l_ = this->report_to_l_;
+  return handle;
+}
+
+Interpretation_context_handle::~Interpretation_context_handle ()
+{
+  if (report_to_l_)
+    down ();
+}
+
 void
 Interpretation_context_handle::up (Translator_group*t)
 {
@@ -31,13 +57,6 @@ Interpretation_context_handle::try_music (Music *m)
   return  report_to_l_->try_music (m);
 }
 
-Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
-{
-  report_to_l_ =0;
-  if (s.report_to_l_)
-    up (s.report_to_l_ );
-}
-
 void
 Interpretation_context_handle::operator = (Interpretation_context_handle const &s)
 {
@@ -61,14 +80,4 @@ Interpretation_context_handle::report_to_l ()const
   return report_to_l_;
 }
 
-Interpretation_context_handle::Interpretation_context_handle()
-{
-  report_to_l_ =0;
-}
-
-Interpretation_context_handle::~Interpretation_context_handle ()
-{
-  if (report_to_l_)
-    down ();
-}
 
index b1697e199eec9eaf4d8c74017ac3b81473bd3c11..bae22a94afddb94a0ef6790a871938c043f64bf3 100644 (file)
 #include "part-combine-music.hh"
 #include "part-combine-music-iterator.hh"
 #include "request.hh"
-#include "request-iterator.hh"
+#include "simple-music-iterator.hh"
 #include "output-property.hh"
 #include "chord-tremolo-iterator.hh"
 
+Music_iterator::Music_iterator ()
+{
+  first_b_ = true;
+}
+
+Music_iterator::Music_iterator (Music_iterator const& src)
+{
+  first_b_ = src.first_b_;
+  handle_ = *src.handle_.clone ();
+  music_l_ = src.music_l_;
+}
+
+Music_iterator::~Music_iterator()
+{
+}
+
 void
 Music_iterator::do_print() const
 {
@@ -94,10 +110,6 @@ Music_iterator::construct_children()
 {
 }
 
-Music_iterator::~Music_iterator()
-{
-}
-
 Moment
 Music_iterator::next_moment() const
 {
@@ -118,11 +130,26 @@ Music_iterator::do_process_and_next (Moment)
 }
 
 bool
-Music_iterator::ok() const
+Music_iterator::ok () const
 {
   return first_b_;
 }
 
+Music*
+Music_iterator::get_music ()
+{
+  if (ok ())
+    return music_l_;
+  return 0;
+}
+
+bool
+Music_iterator::next ()
+{
+  first_b_ = false;
+  return ok ();
+}
+
 Music_iterator*
 Music_iterator::static_get_iterator_p (Music  *m)
 {
@@ -202,11 +229,6 @@ Music_iterator::get_iterator_p (Music *m) const
   return p;
 }
 
-Music_iterator::Music_iterator()
-{
-  first_b_ = true;
-}
-
 Music_iterator*
 Music_iterator::try_music (Music  *m) const
 {
index af658cf72a5905d6345810cd0925f7bc0cb12328..396e9c4657aea44f323c2172a5043fe2dd994f96 100644 (file)
@@ -16,7 +16,16 @@ Music_wrapper_iterator::Music_wrapper_iterator ()
   child_iter_p_ =0;
 }
 
+Music_wrapper_iterator::Music_wrapper_iterator (Music_wrapper_iterator const &src)
+  : Music_iterator (src)
+{
+  child_iter_p_ = src.child_iter_p_->clone ();
+}
 
+Music_wrapper_iterator::~Music_wrapper_iterator ()
+{
+  delete child_iter_p_;
+}
 
 void
 Music_wrapper_iterator::do_print () const
@@ -31,12 +40,6 @@ Music_wrapper_iterator::construct_children ()
     get_iterator_p (dynamic_cast<Music_wrapper const*> (music_l_)->element ());
 }
 
-Music_wrapper_iterator::~Music_wrapper_iterator ()
-{
-  delete child_iter_p_;
-}
-
-
 bool
 Music_wrapper_iterator::ok () const
 {
@@ -50,6 +53,17 @@ Music_wrapper_iterator::do_process_and_next (Moment m)
   Music_iterator::do_process_and_next (m);
 }
 
+Music*
+Music_wrapper_iterator::get_music ()
+{
+  return child_iter_p_->get_music ();
+}
+
+bool
+Music_wrapper_iterator::next ()
+{
+  return child_iter_p_->next ();
+}
 
 Moment
 Music_wrapper_iterator::next_moment () const
index 3a72a587a959865256883b60abb0acd86d56ad94..b5c3780961c2b341664119d2b501d10ba938341b 100644 (file)
 #include "part-combine-music-iterator.hh"
 #include "translator-group.hh"
 #include "musical-request.hh"
+#include "music-sequence.hh"
 #include "warn.hh"
 
 Part_combine_music_iterator::Part_combine_music_iterator ()
 {
-  combined_b_ = true;
-
-  now_ = 0;
   first_iter_p_ = 0;
   second_iter_p_ = 0;
   first_until_ = 0;
@@ -117,110 +115,118 @@ Part_combine_music_iterator::change_to (Music_iterator *it, String to_type,
     error (_f ("none of these in my family: `%s'", to_id.ch_C ()));
 }
 
-Pitch_interrogate_req* first_spanish_inquisition; // nobody expects it
-Pitch_interrogate_req* second_spanish_inquisition; // won't strike twice
-
-Rhythm_interrogate_req* first_rhythmic_inquisition;
-Rhythm_interrogate_req* second_rhythmic_inquisition;
-
 void
 Part_combine_music_iterator::do_process_and_next (Moment m)
 {
   Part_combine_music const * p = dynamic_cast<Part_combine_music const* > (music_l_);
 
-  now_ = next_moment ();
+  Moment now = next_moment ();
 
-  /*
-    Hmm, shouldn't we check per iterator if next_moment < m?
-   */
+  Array<Musical_pitch> first_pitches;
+  Array<Duration> first_durations;
   if (first_iter_p_->ok ())
-    first_iter_p_->process_and_next (m);
-  
-  if (second_iter_p_->ok ())
-    second_iter_p_->process_and_next (m);
-
-  Music_iterator::do_process_and_next (m);
-
-  /*
-    TODO:
-
-    * Maybe we need a Skip_engraver?
-
-    (check): can this all be handled now?
-    
-    Maybe different modes exist?
-
-    * Wind instruments (Flute I/II)
-    * Hymnals:  
-
-
-      Rules for Hymnals/SATB (John Henckel <henckel@iname.com>):
-
-      1. if S and A differ by less than a third, the stems should be up/down.
-      2. else if S and A have different values, the stems should be up/down.
-      3. else if A sings "la" or higher, both S and A stems should be down.
-      4. else both stems should be up
-
-    * This may get really tricky: combining voices/staffs: string instruments
+    {
+      Music_iterator* i = first_iter_p_->clone ();
+      Moment until = i->next_moment ();
+
+      /* Urg, silly first_b_ stuff */
+      if (now && i->next ())
+       until = i->next_moment ();
+
+      /* How about a 'now_moment ()' for iterators? */
+      for (; i->ok () && i->next_moment () == until; i->next ())
+       {
+         if (Music_sequence* m = dynamic_cast<Music_sequence *> (i->get_music ()))
+           {
+             for (SCM s = m->music_list (); gh_pair_p (s);  s = gh_cdr (s))
+               {
+                 Music *u = unsmob_music (gh_car (s));
+                 if (Melodic_req *r = dynamic_cast<Melodic_req *> (u))
+                   first_pitches.push (r->pitch_);
+                 if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (u))
+                   first_durations.push (r->duration_);
+               }
+           }
+       }
+    }
 
-   */
-  
-  if (!first_spanish_inquisition)
-    first_spanish_inquisition = new Pitch_interrogate_req;
-  first_iter_p_->try_music (first_spanish_inquisition);
+  Array<Musical_pitch> second_pitches;
+  Array<Duration> second_durations;
+  if (second_iter_p_->ok ())
+    {
+      Music_iterator* i = second_iter_p_->clone ();
+      Moment until = i->next_moment ();
+
+      /* Urg, silly second_b_ stuff */
+      if (now && i->next ())
+       until = i->next_moment ();
+
+      /* How about a 'now_moment ()' for iterators? */
+      for (; i->ok () && i->next_moment () == until; i->next ())
+       {
+         if (Music_sequence* m = dynamic_cast<Music_sequence *> (i->get_music ()))
+           {
+             for (SCM s = m->music_list (); gh_pair_p (s);  s = gh_cdr (s))
+               {
+                 Music *u = unsmob_music (gh_car (s));
+                 if (Melodic_req *r = dynamic_cast<Melodic_req *> (u))
+                   second_pitches.push (r->pitch_);
+                 if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (u))
+                   second_durations.push (r->duration_);
+               }
+           }
+       }
+    }
   
-  if (!second_spanish_inquisition)
-    second_spanish_inquisition = new Pitch_interrogate_req;
-  second_iter_p_->try_music (second_spanish_inquisition);
-
-  Array<Musical_pitch>* first_pitches = &first_spanish_inquisition->pitch_arr_;
-  Array<Musical_pitch>* second_pitches = &second_spanish_inquisition->pitch_arr_;
-
-  if (!first_rhythmic_inquisition)
-    first_rhythmic_inquisition = new Rhythm_interrogate_req;
-  first_iter_p_->try_music (first_rhythmic_inquisition);
-
-  if (!second_rhythmic_inquisition)
-    second_rhythmic_inquisition = new Rhythm_interrogate_req;
-  second_iter_p_->try_music (second_rhythmic_inquisition);
-
-  Array<Duration>* first_durations = &first_rhythmic_inquisition->duration_arr_;
-  Array<Duration>* second_durations = &second_rhythmic_inquisition->duration_arr_;
-
   SCM interval = SCM_BOOL_F;
-  if (first_pitches->size () && second_pitches->size ())
+  if (first_pitches.size () && second_pitches.size ())
     {
-      first_pitches->sort (Musical_pitch::compare);
-      second_pitches->sort (Musical_pitch::compare);
-      interval = gh_int2scm (first_pitches->top ().steps ()
-                            - (*second_pitches)[0].steps ());
+      first_pitches.sort (Musical_pitch::compare);
+      second_pitches.sort (Musical_pitch::compare);
+      interval = gh_int2scm (first_pitches.top ().steps ()
+                            - second_pitches[0].steps ());
     }
-  if (first_durations->size ())
+  if (first_durations.size ())
     {
-      first_durations->sort (Duration::compare);
-      Moment new_until = now_ + first_durations->top ().length_mom ();
+      first_durations.sort (Duration::compare);
+      Moment new_until = now + first_durations.top ().length_mom ();
       if (new_until > first_until_)
        first_until_ = new_until;
     }
 
-    if (second_durations->size ())
+    if (second_durations.size ())
     {
-      second_durations->sort (Duration::compare);
-      Moment new_until = now_ + second_durations->top ().length_mom ();
+      second_durations.sort (Duration::compare);
+      Moment new_until = now + second_durations.top ().length_mom ();
       if (new_until > second_until_)
        second_until_ = new_until;
     }
 
+#if 0 /* DEBUG */
+  printf ("now: %s\n", now.str ().ch_C ());
+  printf ("first: ");
+  for (int i = 0; i < first_pitches.size (); i++)
+    {
+      printf ("%s, ", first_pitches[i].str ().ch_C ());
+    }
+  printf ("\nsecond: ");
+  for (int i = 0; i < second_pitches.size (); i++)
+    {
+      printf ("%s, ", second_pitches[i].str ().ch_C ());
+    }
+  printf ("\n");
+#endif
+
   Translator_group * fir = first_iter_p_->report_to_l ();
   Translator_group * sir = second_iter_p_->report_to_l ();
 
-  bool solo_b = (first_pitches->empty () != second_pitches->empty ())
-    && !(first_until_ > now_ && second_until_ > now_);
+  bool solo_b = (first_pitches.empty () != second_pitches.empty ())
+    && !(first_until_ > now && second_until_ > now);
 
-  bool unirhythm_b = !solo_b && !compare (first_durations, second_durations);
-  bool unison_b = unirhythm_b && !first_pitches->empty ()
-    &&!compare (first_pitches, second_pitches);
-  bool unisilence_b = unirhythm_b && first_pitches->empty ();
+  bool unirhythm_b = !solo_b && !compare (&first_durations, &second_durations);
+  bool unison_b = unirhythm_b && !first_pitches.empty ()
+    &&!compare (&first_pitches, &second_pitches);
+  bool unisilence_b = unirhythm_b && first_pitches.empty ();
 
   Translator_group * fd = fir->find_create_translator_l (p->what_str_, "one");
   Translator_group * sd = sir->find_create_translator_l (p->what_str_, "two");
@@ -238,28 +244,23 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
        split_interval_b = true;
     }
 
-  /*
-    Hmm, maybe we should set/check combined_b_ against
+  bool combined_b = first_iter_p_->report_to_l ()->daddy_trans_l_
+    == second_iter_p_->report_to_l ()->daddy_trans_l_;
 
-       first_iter_p_->report_to_l () == second_iter_p_->report_to_l ()
-
-   ? 
-   */
-
-  String to_id =  combined_b_ ? "one" : "two";
-  if ((!unirhythm_b && combined_b_)
-      || (split_interval_b && combined_b_)
-      || (solo_b && combined_b_)
-      /*|| (unisilence_b && combined_b_) */
+  String to_id =  combined_b ? "one" : "two";
+  if ((!unirhythm_b && combined_b)
+      || (split_interval_b && combined_b)
+      || (solo_b && combined_b)
+      /*|| (unisilence_b && combined_b) */
       || ((unirhythm_b || unison_b || unisilence_b)
-         && !combined_b_ && !split_interval_b && !solo_b))
+         && !combined_b && !split_interval_b && !solo_b))
     {
-      combined_b_ = !combined_b_;
-      to_id =  combined_b_ ? "one" : "two";
+      combined_b = !combined_b;
+      to_id =  combined_b ? "one" : "two";
       change_to (second_iter_p_, p->what_str_, to_id);
     }
 
-  if (!combined_b_)
+  if (!combined_b)
     sir = second_iter_p_->report_to_l ();
 
   SCM b = unirhythm_b ? SCM_BOOL_T : SCM_BOOL_F;
@@ -279,22 +280,28 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
   sd->set_property ("unison", b);
 
   b = solo_b  ? SCM_BOOL_T : SCM_BOOL_F;
-  if (first_pitches->size ())
+  if (first_pitches.size ())
     {
       fd->set_property ("solo", b);
       sd->set_property ("solo", SCM_BOOL_F);
     }
 
-  if (second_pitches->size ())
+  if (second_pitches.size ())
     {
       fd->set_property ("solo", SCM_BOOL_F);
       sd->set_property ("solo", b);
     }
 
-  first_pitches->clear ();
-  second_pitches->clear ();
-  first_durations->clear ();
-  second_durations->clear ();
+  /*
+    Hmm, shouldn't we check per iterator if next_moment < m?
+  */
+  if (first_iter_p_->ok ())
+    first_iter_p_->process_and_next (m);
+  
+  if (second_iter_p_->ok ())
+    second_iter_p_->process_and_next (m);
+
+  Music_iterator::do_process_and_next (m);
 }
 
 Music_iterator*
index 7f0b00827f96e47beaa47fdb16b964f43d5c8411..7ac4c2e2c7a6c507a0089bacd8e5a9b08f8bc64d 100644 (file)
 #include "music-list.hh"
 #include "request.hh"
 
+Request_chord_iterator::Request_chord_iterator ()
+{
+  last_b_ = false;
+}
 
+Request_chord_iterator::Request_chord_iterator (Request_chord_iterator const &src)
+  : Music_iterator (src)
+{
+  last_b_ = src.last_b_;
+  elt_length_mom_ = src.elt_length_mom_;
+}
 
 void
 Request_chord_iterator::construct_children()
@@ -27,12 +37,6 @@ Request_chord_iterator::elt_l () const
   return (Request_chord*) music_l_;
 }
 
-Request_chord_iterator::Request_chord_iterator ()
-{
-  last_b_ = false;
-}
-
-
 bool
 Request_chord_iterator::ok() const
 {
@@ -57,12 +61,23 @@ Request_chord_iterator::do_print() const
 #endif
 }
 
+bool
+Request_chord_iterator::next ()
+{
+  if (first_b_)
+    first_b_ = false;
+  else
+    last_b_ = true;
+  return ok ();
+}
+
 void
-Request_chord_iterator::do_process_and_next (Moment mom)
+Request_chord_iterator::do_process_and_next (Moment)
 {
+  // URG
   if (first_b_)
     {
-      for (SCM s = dynamic_cast<Music_sequence *> (music_l_)->music_list (); gh_pair_p (s);  s = gh_cdr (s))
+      for (SCM s = dynamic_cast<Music_sequence *> (get_music ())->music_list (); gh_pair_p (s);  s = gh_cdr (s))
        {
          Music *mus = unsmob_music (gh_car (s));
          if (Request * req_l = dynamic_cast<Request*> (mus))
@@ -75,9 +90,7 @@ Request_chord_iterator::do_process_and_next (Moment mom)
            mus->origin ()->warning (_f ("Huh?  Not a Request: `%s'",
                                                 classname (mus)));
                    }
-      first_b_ = false;
     }
 
-  if (mom >= elt_length_mom_)
-    last_b_ = true;
+  next ();
 }
index 51c7604281988204c346c1a4f3a40354796abeea..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,25 +0,0 @@
-/*   
-  request-iterator.cc --  implement Simple_music_iterator
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-#include "request-iterator.hh"
-#include "music.hh"
-#include "input.hh"
-
-void
-Simple_music_iterator::do_process_and_next (Moment m)
-{
-  if (first_b_)
-    {
-      bool g= try_music (music_l_);
-      if (!g)
-       music_l_->origin ()->warning (_f ("Junking music: `%s'", classname(music_l_)));
-
-      first_b_ = false;
-    }
-  Music_iterator::do_process_and_next (m);
-}
index d99381cf5415a8645039c6251cf44388c58e6575..8ba2fa20db418aeca4c9880c98fae5f94deec8f3 100644 (file)
 #include "music-list.hh"
 #include "request-chord-iterator.hh"
 
+Sequential_music_iterator::Sequential_music_iterator ()
+{
+  cursor_ = 0;
+  here_mom_ = 0;
+  iter_p_ =0;
+}
 
-void
-Sequential_music_iterator::do_print() const
+Sequential_music_iterator::Sequential_music_iterator (Sequential_music_iterator const &src)
+  : Music_iterator (src)
+{
+  cursor_ = src.cursor_;
+  here_mom_ = src.here_mom_;
+  iter_p_ = src.iter_p_->clone ();
+}
+
+Sequential_music_iterator::~Sequential_music_iterator()
 {
   if (iter_p_)
-    iter_p_->print();
+    {
+      if (iter_p_->ok ())
+       music_l_->origin ()->warning (_ ("Must stop before this music ends"));
+      delete iter_p_;
+      iter_p_ = 0;
+    }
 }
 
-Sequential_music_iterator::Sequential_music_iterator ()
+void
+Sequential_music_iterator::do_print() const
 {
-  cursor_ = 0;
-  here_mom_ = 0;
-  iter_p_ =0;
+  if (iter_p_)
+    iter_p_->print();
 }
 
 void
@@ -75,50 +93,68 @@ Sequential_music_iterator::set_sequential_music_translator()
     set_translator (child_report);
 }
 
-Sequential_music_iterator::~Sequential_music_iterator()
+Music*
+Sequential_music_iterator::get_music ()
 {
-  if (iter_p_)
+  if (ok ())
+    return unsmob_music (gh_car (cursor_));
+      
+  return 0;
+}
+  
+bool
+Sequential_music_iterator::next ()
+{
+  if (ok ())
     {
+      bool b = false;
       if (iter_p_->ok ())
-       music_l_->origin ()->warning (_ ("Must stop before this music ends"));
-      delete iter_p_;
-      iter_p_ = 0;
+       b = iter_p_->next ();
+      if (!b)
+       {
+         set_sequential_music_translator ();
+         leave_element ();
+         if (gh_pair_p (cursor_))
+           start_next_element ();
+         b = ok ();
+       }
+      return b;
     }
+  return false;
 }
 
+/*
+  This should use get_music () and next ()
+ */
 void
 Sequential_music_iterator::do_process_and_next (Moment until)
 {
-  if (!iter_p_)
-    return;
-
-  while (1) 
+  if (ok ())
     {
-      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()) 
+      while (1) 
        {
-         set_sequential_music_translator();
-         leave_element();
+         Moment local_until = until - here_mom_;
+         while (iter_p_->ok ()) 
+           {
+             Moment here = iter_p_->next_moment ();
+             if (here != local_until)
+               return Music_iterator::do_process_and_next (until);
+             
+             iter_p_->process_and_next (local_until);
+           }
          
-         if (gh_pair_p (cursor_))
-           start_next_element();
-         else 
-           goto loopexit;
+         if (!iter_p_->ok ()) 
+           {
+             set_sequential_music_translator ();
+             leave_element ();
+             
+             if (gh_pair_p (cursor_))
+               start_next_element ();
+             else 
+               return Music_iterator::do_process_and_next (until);
+           }
        }
     }
-
-loopexit:
-
-  Music_iterator::do_process_and_next (until);
 }
 
 Moment
diff --git a/lily/simple-music-iterator.cc b/lily/simple-music-iterator.cc
new file mode 100644 (file)
index 0000000..d19d615
--- /dev/null
@@ -0,0 +1,36 @@
+/*   
+  simple-music-iterator.cc --  implement Simple_music_iterator
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#include "simple-music-iterator.hh"
+#include "music.hh"
+#include "input.hh"
+
+Simple_music_iterator::Simple_music_iterator ()
+  : Music_iterator ()
+{
+}
+
+Simple_music_iterator::Simple_music_iterator (Simple_music_iterator const &src)
+  : Music_iterator (src)
+{
+}
+
+void
+Simple_music_iterator::do_process_and_next (Moment m)
+{
+  if (ok ())
+    {
+      bool b = try_music (get_music ());
+      if (!b)
+       music_l_->origin ()->warning (_f ("Junking music: `%s'",
+                                         classname (music_l_)));
+
+    }
+  Music_iterator::do_process_and_next (m);
+}
index 5ea7f712186579e8b819b19e7301be464a293e64..3e4d821ede7abf64053928486ab04ed7f473a9cc 100644 (file)
 Simultaneous_music_iterator::Simultaneous_music_iterator ()
 {
   separate_contexts_b_ = false;
+  cursor_i_ = 0;
+}
+
+Simultaneous_music_iterator::Simultaneous_music_iterator (Simultaneous_music_iterator const& src)
+  : Music_iterator (src)
+{
+  cursor_i_ = src.cursor_i_;
+  separate_contexts_b_ = src.separate_contexts_b_;
+  for (Cons<Music_iterator> *p = children_p_list_.head_; p; p = p->next_)
+    {
+      Music_iterator *i = p->car_;
+      children_p_list_.append (new Killing_cons<Music_iterator> (i->clone (), 0));
+    }
 }
 
 Simultaneous_music_iterator::~Simultaneous_music_iterator ()
@@ -22,6 +35,28 @@ Simultaneous_music_iterator::~Simultaneous_music_iterator ()
   children_p_list_.junk ();
 }
 
+bool
+Simultaneous_music_iterator::next ()
+{
+  if (cursor_i_ < children_p_list_.size_i ())
+    cursor_i_++;
+  return cursor_i_ < children_p_list_.size_i ();
+}
+
+Music*
+Simultaneous_music_iterator::get_music ()
+{
+  if (cursor_i_ < children_p_list_.size_i ())
+    {
+      Cons<Music_iterator> *p = children_p_list_.head_;
+      for (int i = 0; i <= cursor_i_ && p; i++)
+       p = p->next_;
+      if (p)
+       return p->car_->get_music ();
+    }
+  return 0;
+}
+
 void
 Simultaneous_music_iterator::construct_children()
 {
index 19b54bb2aab51f4525d78951cde98d455e70ce45..0477d3e645581a067ae1d7937adc60377eb898c4 100644 (file)
@@ -33,7 +33,8 @@ Translator_group::properties_dict () const
 
 Translator_group::~Translator_group ()
 {
-  assert (removable_b());
+  
+  //assert (removable_b());
 }