2 music-iterator.hh -- declare Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #ifndef MUSIC_ITERATOR_HH
10 #define MUSIC_ITERATOR_HH
14 #include "virtual-methods.hh"
15 #include "context-handle.hh"
20 Music_iterator is an object type that traverses the Music structure and
21 reports the events it finds to interpretation contexts. It is not yet
27 Conceptually a music-iterator operates on a queue of musical events
28 that are pending. This queue does not actually exist, but it is a
29 way of viewing and traversing music-expressions.
32 ok () -- events left ?
34 pending_mom () -- time tag of the next event to be processed.
35 PRECONDITION: this->ok () holds.
37 process (M) -- process all at M (Precondition: no events exist
38 before M, this->ok () holds). Side-effects:
40 * This removes all events at M from the pending queue.
42 * Typically this reports the music to an interpretation context,
43 thus changing the state of the interpretation context.
48 merge pending_moment and process?
56 DECLARE_SMOBS (Music_iterator, dummy);
57 Music_iterator (Music_iterator const &);
60 Moment music_get_length () const;
61 Moment music_start_mom () const;
63 Music_iterator *try_music (Music *) const;
64 Context *get_outlet () const;
65 void set_context (Context *);
66 static SCM get_static_get_iterator (Music *mus);
67 void init_translator (Music *, Context *);
69 void substitute_outlet (Context *from, Context *to);
70 virtual void derived_substitute (Context *, Context *);
71 virtual Moment pending_moment () const;
72 virtual bool ok () const;
73 virtual bool run_always () const;
74 virtual void process (Moment until);
75 virtual void derived_mark () const;
76 virtual void construct_children ();
77 DECLARE_SCHEME_CALLBACK (constructor, ());
78 SCM get_iterator (Music *) const;
80 virtual Music_iterator *try_music_in_children (Music *) const;
82 Music *get_music () const;
84 virtual void do_quit ();
85 void descend_to_child (Context *);
88 Context_handle handle_;
92 bool is_child_context (Context *me, Context *child);
94 #define IMPLEMENT_CTOR_CALLBACK(Class) \
95 LY_DEFINE_MEMBER_FUNCTION (Class, constructor, #Class "::constructor", \
100 Class *c = (new Class); \
101 return c->unprotect (); \
104 DECLARE_UNSMOB (Music_iterator, iterator);
106 #endif // MUSIC_ITERATOR_HH