2 music-iterator.hh -- declare Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 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"
18 #include "cxx-function-smob.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.
48 get_pending_events (M) -- return all events starting at M (pre: no events
49 before M). No side-effects
51 skip (M) -- remove all events starting before M (leave the ones that
52 start M). no side-effects on interpretation context
57 merge pending_moment and process?
66 VIRTUAL_COPY_CONS (Music_iterator);
68 Moment music_length_mom () const;
69 Moment music_start_mom () const;
71 Music_iterator (Music_iterator const&);
72 virtual ~Music_iterator ();
75 Do the reporting. Will try MUSIC_L_ in its own translator first,
76 then its children. Returns the iterator that succeeded
78 Music_iterator * try_music (Music *) const;
81 The translation unit that we this iterator is reporting to now.
83 Translator_group* report_to () const;
85 void set_translator (Translator_group*);
87 /** Get an iterator matching the type of MUS, and use TRANS to find
88 an accompanying translation unit
90 static Music_iterator* get_static_get_iterator (Music * mus);
91 void init_translator (Music *, Translator_group *);
93 virtual Moment pending_moment () const;
94 virtual bool ok () const;
95 virtual SCM get_pending_events (Moment until)const;
96 virtual void process (Moment until);
97 virtual void skip (Moment until);
100 Construct sub-iterators, and set the translator to
103 virtual void construct_children ();
104 static SCM constructor_cxx_function;
107 Get an iterator for MUS, inheriting the translation unit from THIS.
109 Music_iterator* get_iterator (Music *) const;
111 virtual Music_iterator* try_music_in_children (Music *) const;
113 Music * get_music () const;
115 Interpretation_context_handle handle_;
121 implement Class::constructor, a SCM function that
122 returns an encapsulated factory function.
124 #define IMPLEMENT_CTOR_CALLBACK(Class) \
126 Class ## _ctor (SCM) \
130 SCM Class :: constructor_cxx_function;\
132 Class ## _constructor_init () \
134 SCM s = smobify_cxx_function (& Class ## _ctor); \
135 scm_permanent_object (s);\
136 gh_define (#Class "::constructor", s);\
137 Class :: constructor_cxx_function = s;\
139 ADD_SCM_INIT_FUNC (Class ## _ctor_init, Class ## _constructor_init);
147 #endif // MUSIC_ITERATOR_HH