2 music-iterator.hh -- declare Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #ifndef MUSIC_ITERATOR_HH
11 #define MUSIC_ITERATOR_HH
15 #include "virtual-methods.hh"
16 #include "interpretation-context-handle.hh"
21 Music_iterator is an object type that traverses the Music structure and
22 reports the events it finds to interpretation contexts. It is not yet
28 Conceptually a music-iterator operates on a queue of musical events
29 that are pending. This queue does not actually exist, but it is a
30 way of viewing and traversing music-expressions.
33 ok () -- events left ?
35 pending_mom () -- time tag of the next event to be processed.
36 PRECONDITION: this->ok () holds.
38 process (M) -- process all at M (Precondition: no events exist
39 before M, this->ok () holds). Side-effects:
41 * This removes all events at M from the pending queue.
43 * Typically this reports the music to an interpretation context,
44 thus changing the state of the interpretation context.
49 merge pending_moment and process?
58 DECLARE_SMOBS (Music_iterator,dummy);
59 Music_iterator (Music_iterator const&);
62 Moment music_get_length () const;
63 virtual Moment music_start_mom () const;
67 Do the reporting. Will try MUSIC_L_ in its own translator first,
68 then its children. Returns the iterator that succeeded
70 Music_iterator * try_music (Music *) const;
73 The translation unit that we this iterator is reporting to now.
75 Context * get_outlet () const;
77 void set_context (Context *);
79 /** Get an iterator matching the type of MUS, and use TRANS to find
80 an accompanying translation unit
82 static SCM get_static_get_iterator (Music * mus);
83 void init_translator (Music *, Context *);
85 void substitute_outlet (Context * from, Context *to);
86 virtual void derived_substitute (Context *, Context *);
87 virtual Moment pending_moment () const;
88 virtual bool ok () const;
90 virtual bool run_always () const;
91 virtual void process (Moment until);
92 virtual void derived_mark () const;
93 virtual void construct_children ();
96 Construct sub-iterators, and set the translator to
100 DECLARE_SCHEME_CALLBACK(constructor, ());
103 Get an iterator for MUS, inheriting the translation unit from THIS.
105 SCM get_iterator (Music *) const;
107 virtual Music_iterator* try_music_in_children (Music *) const;
109 Music * get_music () const;
111 virtual void do_quit();
112 void descend_to_child (Context*);
114 Interpretation_context_handle handle_;
118 bool is_child_context (Context *me, Context *child);
120 #define IMPLEMENT_CTOR_CALLBACK(Class) \
121 LY_DEFINE_MEMBER_FUNCTION(Class,constructor, #Class "::constructor",\
126 SCM val = (new Class)->self_scm(); \
127 scm_gc_unprotect_object (val);\
131 DECLARE_UNSMOB(Music_iterator, iterator);
133 #endif // MUSIC_ITERATOR_HH