]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/music-iterator.hh
patch::: 1.3.86.jcn2
[lilypond.git] / lily / include / music-iterator.hh
1 /*
2   music-iterator.hh -- declare Music_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef MUSIC_ITERATOR_HH
11 #define MUSIC_ITERATOR_HH
12
13 #include "lily-proto.hh"
14 #include "array.hh"
15 #include "moment.hh"
16 #include "virtual-methods.hh"
17 #include "interpretation-context-handle.hh"
18
19 /** Walk through music and deliver music to translation units, synced
20   in time.  This class provides both the implementation of the shared
21   code, and the public interface.
22
23   Derived classes should only have a public constructor.
24   The state of an iterator would be the intersection of the particular music 
25   construct with one point in musical time.
26  */
27 class Music_iterator
28 {
29 public:
30   VIRTUAL_COPY_CONS (Music_iterator);
31
32   Music_iterator ();
33   Music_iterator (Music_iterator const&);
34   virtual ~Music_iterator ();
35
36   /**
37      Do the reporting.  Will try MUSIC_L_ in its own translator first,
38      then its children. Returns the iterator that succeeded
39   */
40   Music_iterator *  try_music (Music  *) const;
41
42   /**
43     The translation unit that we this iterator is reporting  to now.
44    */
45   Translator_group* report_to_l () const;
46
47   void set_translator (Translator_group*);
48   
49   /** Get an iterator matching the type of MUS, and use TRANS to find
50     an accompanying translation unit
51    */
52   static Music_iterator* static_get_iterator_p (Music * mus);
53   void init_translator (Music  *, Translator_group *); 
54
55   ///  Find the next interesting point in time.
56   virtual Moment next_moment () const;
57
58
59   ///Are we finished with this piece of music?
60   virtual bool ok () const;
61
62   virtual SCM get_music ();
63   virtual bool next ();
64
65   void process (Moment until);
66
67   /**
68     Construct sub-iterators, and set the translator to 
69     report to.
70    */
71   virtual void construct_children ();
72   void print () const;
73
74 protected:
75   Music  * music_l_;
76
77   /// ugh. JUNKME
78   bool first_b_;
79
80   /**
81     Do the actual printing.  This should be overriden in derived classes.  It 
82     is called by #print#, in the public interface
83    */
84   virtual void do_print () const;
85     
86   /**
87     Find a bottom notation context to deliver requests to.
88    */
89   virtual Translator_group* get_req_translator_l ();
90
91   /**
92     Get an iterator for MUS, inheriting the translation unit from THIS.
93    */
94   Music_iterator* get_iterator_p (Music *) const;
95
96   virtual void do_process (Moment);
97
98   virtual Music_iterator* try_music_in_children (Music *) const;
99   
100 private:
101   Interpretation_context_handle handle_;
102 };
103
104 #endif // MUSIC_ITERATOR_HH