]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/sequential-iterator.hh
* VERSION (MY_PATCH_LEVEL): make 1.7.0
[lilypond.git] / lily / include / sequential-iterator.hh
1 /*   
2   sequential-iterator.hh -- declare Sequential_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #ifndef SEQUENTIAL_ITERATOR_HH
10 #define SEQUENTIAL_ITERATOR_HH
11
12 #include "music-iterator.hh"
13 #include "protected-scm.hh"
14
15 /*
16
17   This is a lookahead list for grace notes.
18
19    {  ... X \grace Y  Z ... }
20
21    normally, the ending of X is the start of Z. In case of a grace
22    note, we take off a little at the end of X. What is stored: START
23    (start point of X), LENGTH (length of X), GRACE_START (start_music
24    of Y), and the next fixup element.
25
26   This is also done for nested musics, i.e.
27
28   voiceA = \notes { \grace b16 c'2 }
29   voiceB = \notes { c'2 \voiceA }
30
31   the iterator for voiceB will contain a fixup entry with (START=0/1,
32   LENGTH=2/1, GRACE_START=(0G-1/16) ) 
33    
34   Graces at the start of a sequential music iterator are handled
35   by initting here_mom_ with Music::start_music (); no fixups are needed.
36
37 */
38 struct Grace_fixup 
39 {
40   Moment start_;
41   Moment length_;
42
43   Rational grace_start_;  
44   Grace_fixup *next_;
45 };
46
47 /** Sequential_music iteration: walk each element in turn, and
48   construct an iterator for every element.
49   
50  */
51 class Sequential_iterator :  public Music_iterator
52 {
53 public:
54   Grace_fixup * grace_fixups_;
55   
56   VIRTUAL_COPY_CONS (Music_iterator);
57   DECLARE_SCHEME_CALLBACK(constructor, ());
58   Sequential_iterator ();
59   Sequential_iterator (Sequential_iterator const&);
60   virtual void derived_mark () const;
61
62   virtual void construct_children ();
63   virtual Moment pending_moment () const;
64   virtual void do_quit(); 
65   virtual bool ok () const;
66   virtual void skip (Moment);
67   virtual SCM get_pending_events (Moment)const;
68
69 protected:
70   virtual void process (Moment);
71   virtual Music_iterator *try_music_in_children (Music *) const;
72
73 protected:
74   Moment here_mom_;
75   Music_iterator * iter_;
76   SCM  list_;
77   SCM cursor_;
78   
79   virtual void next_element (bool side_effect);
80   virtual void descend_to_child ();
81   virtual SCM get_music_list ()const;
82 };
83
84 #endif /* SEQUENTIAL_ITERATOR_HH */