2 music-iterator.hh -- declare Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #ifndef MUSIC_ITERATOR_HH
10 #define MUSIC_ITERATOR_HH
12 #include "std-vector.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_CLASSNAME(Music_iterator);
57 DECLARE_SMOBS (Music_iterator);
58 Music_iterator (Music_iterator const &);
61 Moment music_get_length () const;
62 Moment music_start_mom () const;
64 void report_event (Music *);
65 Context *get_outlet () const;
66 void set_context (Context *);
67 static SCM get_static_get_iterator (Music *mus);
68 void init_context (Music *, Context *);
70 void substitute_outlet (Context *from, Context *to);
71 void descend_to_bottom_context ();
72 virtual void derived_substitute (Context *, Context *);
73 virtual Moment pending_moment () const;
74 virtual bool ok () const;
75 virtual bool run_always () const;
76 virtual void process (Moment until);
77 virtual void derived_mark () const;
78 virtual void construct_children ();
79 DECLARE_SCHEME_CALLBACK (constructor, ());
80 SCM get_iterator (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, \
96 mangle_cxx_identifier (string (#Class) + "::constructor").c_str(), \
101 Class *c = (new Class); \
102 return c->unprotect (); \
105 DECLARE_UNSMOB (Music_iterator, iterator);
107 #endif // MUSIC_ITERATOR_HH