]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/music-iterator.hh
d5ca0e0560dbea0c1c19a31d432118fe0b3bc054
[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--1999 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   Interpretation_context_handle handle_;
29
30 protected:
31   bool playback_b_;             // Should use SCMs
32   
33   Music const * music_l_;
34
35   /// ugh. JUNKME
36   bool first_b_;
37
38   /**
39     Do the actual printing.  This should be overriden in derived classes.  It 
40     is called by #print#, in the public interface
41    */
42   virtual void do_print() const;
43     
44   /**
45     Find a bottom notation context to deliver requests to.
46    */
47   virtual Translator_group* get_req_translator_l();
48
49   /**
50     Get an iterator for MUS, inheriting the translation unit from THIS.
51    */
52   Music_iterator* get_iterator_p (Music const*mus) const;
53
54   /** Do the actual move.  This should be overriden in derived
55     classes.  It is called by #process_and_next#, the public interface 
56     */
57   virtual void do_process_and_next (Moment until);
58
59
60   virtual Music_iterator* try_music_in_children (Music const *) const;
61   
62 public:
63
64   /**
65      Do the reporting.  Will try MUSIC_L_ in its own translator first,
66      then its children. Returns the iterator that succeeded
67   */
68   Music_iterator *  try_music (Music const *) const;
69
70   /**
71     The translation unit that we this iterator is reporting  to now.
72    */
73   Translator_group*report_to_l() const;
74
75   void set_translator (Translator_group*);
76   
77   /** Get an iterator matching the type of MUS, and use TRANS to find
78     an accompanying translation unit.  Repeated music can be fully
79     unfolded by setting PLAYING */
80   static Music_iterator* static_get_iterator_p (Music const* mus, bool playing);
81   void init_translator (Music const *, Translator_group *); 
82
83   Music_iterator();
84     
85   ///  Find the next interesting point in time.
86   virtual Moment next_moment() const;
87
88
89   ///Are we finished with this piece of music?
90   virtual bool ok() const;
91
92   virtual ~Music_iterator();
93
94
95   ///Report all musical information that occurs between now and UNTIL
96   void process_and_next (Moment until);
97
98   /**
99     Construct sub-iterators, and set the translator to 
100     report to.
101    */
102   virtual void construct_children();
103   void print() const;
104 };
105
106 #endif // MUSIC_ITERATOR_HH