2 music-iterator.hh -- declare Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #ifndef MUSIC_ITERATOR_HH
11 #define MUSIC_ITERATOR_HH
13 #include "lily-proto.hh"
16 #include "virtual-methods.hh"
17 #include "interpretation-context-handle.hh"
23 Music_iterator is an object type that traverses the Music structure and
24 reports the events it finds to interpretation contexts. It is not yet
30 Conceptually a music-iterator operates on a queue of musical events
31 that are pending. This queue does not actually exist, but it is a
32 way of viewing and traversing music-expressions.
35 ok () -- events left ?
37 pending_mom () -- time tag of the next event to be processed.
38 PRECONDITION: this->ok () holds.
40 process (M) -- process all at M (Precondition: no events exist
41 before M, this->ok () holds). Side-effects:
43 * This removes all events at M from the pending queue.
45 * Typically this reports the music to an interpretation context,
46 thus changing the state of the interpretation context.
51 merge pending_moment and process?
60 DECLARE_SMOBS (Music_iterator,dummy);
62 VIRTUAL_COPY_CONS (Music_iterator);
64 Moment music_get_length () const;
65 Moment music_start_mom () const;
67 Music_iterator (Music_iterator const&);
70 Do the reporting. Will try MUSIC_L_ in its own translator first,
71 then its children. Returns the iterator that succeeded
73 Music_iterator * try_music (Music *) const;
76 The translation unit that we this iterator is reporting to now.
78 Translator_group* get_outlet () const;
80 void set_translator (Translator_group*);
82 /** Get an iterator matching the type of MUS, and use TRANS to find
83 an accompanying translation unit
85 static SCM get_static_get_iterator (Music * mus);
86 void init_translator (Music *, Translator_group *);
88 void substitute_outlet (Translator_group* from, Translator_group *to);
89 virtual void derived_substitute (Translator_group*, Translator_group*);
90 virtual Moment pending_moment () const;
91 virtual bool ok () const;
93 virtual bool run_always () const;
94 virtual void process (Moment until);
95 virtual void derived_mark ()const;
96 virtual void construct_children ();
99 Construct sub-iterators, and set the translator to
103 DECLARE_SCHEME_CALLBACK(constructor, ());
106 Get an iterator for MUS, inheriting the translation unit from THIS.
108 SCM get_iterator (Music *) const;
110 virtual Music_iterator* try_music_in_children (Music *) const;
112 Music * get_music () const;
114 virtual void do_quit();
116 Interpretation_context_handle handle_;
121 #define IMPLEMENT_CTOR_CALLBACK(Class) \
122 LY_DEFINE_MEMBER_FUNCTION(Class,constructor, #Class "::constructor",\
125 "Construct a @code{" #Class "} music iterator")\
127 SCM val = (new Class)->self_scm(); \
128 scm_gc_unprotect_object (val);\
132 DECLARE_UNSMOB(Music_iterator, iterator);
134 #endif // MUSIC_ITERATOR_HH