]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/music-iterator.hh
release: 1.1.7
[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--1998 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 "plist.hh"
15 #include "array.hh"
16 #include "moment.hh"
17 #include "virtual-methods.hh"
18
19 /** Walk through music and deliver music to translation units, synced
20   in time.  This classa 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   Array<Translator_group*>report_to_l_arr_;
29   void push_translator (Translator_group*);
30   void pop_translator();
31
32 protected:
33   Music const * music_l_;
34   bool first_b_;
35
36   /**
37     Do the actual printing.  This should be overriden in derived classes.  It 
38     is called by #print#, in the public interface
39    */
40   virtual void do_print() const;
41     
42   /**
43     Find a bottom notation context to deliver requests to.
44    */
45   virtual Translator_group* get_req_translator_l();
46
47   /**
48     Get an iterator for MUS, inheriting the translation unit from THIS.
49    */
50   Music_iterator* get_iterator_p (Music const*mus) const;
51   void set_translator (Translator_group*);
52
53   /** Do the actual reporting.  This should be overriden in derived
54     classes.  It is called by #process_and_next#, the public interface 
55     */
56   virtual void do_process_and_next (Moment until);
57
58 public:
59
60   /**
61     The translation unit that we this iterator is reporting  to now.
62    */
63   Translator_group*report_to_l() const;
64
65   
66   /** Get an iterator matching the type of MUS, and use TRANS to find
67     an accompanying translation unit
68    */
69   static Music_iterator* static_get_iterator_p (Music const* mus,Translator_group* trans);
70
71   Music_iterator();
72     
73   ///  Find the next interesting point in time.
74   virtual Moment next_moment() const;
75
76   ///Are we finished with this piece of music?
77   virtual bool ok() const;
78
79   virtual ~Music_iterator();
80
81
82   ///Report all musical information that occurs between now and UNTIL
83   void process_and_next (Moment until);
84
85   /**
86     Construct sub-iterators, and set the translator to 
87     report to.
88    */
89   virtual void construct_children();
90   void print() const;
91 };
92
93 #endif // MUSIC_ITERATOR_HH