2 music-iterator.hh -- declare Music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 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"
21 Conceptually a music-iterator operates on a queue of musical events
22 that are pending. This queue does not actually exist, but it is a
23 way of viewing and traversing music-expressions.
26 ok () -- events left ?
28 pending_mom () -- time tag of the next event to be processed.
29 PRECONDITION: this->ok () holds.
31 process (M) -- process all at M (Precondition: no events exist
32 before M, this->ok () holds). Side-effects:
34 * This removes all events at M from the pending queue.
36 * Typically this reports the music to an interpretation context,
37 thus changing the state of the interpretation context.
39 get_music (M) -- return all events starting at M (pre: no events
40 before M). No side-effects
42 skip (M) -- remove all events starting before M (leave the ones that
43 start M). no side-effects on interpretation context
48 merge pending_moment and process?
57 VIRTUAL_COPY_CONS (Music_iterator
);
59 Moment
music_length_mom () const;
60 Moment
music_start_mom () const;
62 Music_iterator (Music_iterator
const&);
63 virtual ~Music_iterator ();
66 Do the reporting. Will try MUSIC_L_ in its own translator first,
67 then its children. Returns the iterator that succeeded
69 Music_iterator
* try_music (Music
*) const;
72 The translation unit that we this iterator is reporting to now.
74 Translator_group
* report_to_l () const;
76 void set_translator (Translator_group
*);
78 /** Get an iterator matching the type of MUS, and use TRANS to find
79 an accompanying translation unit
81 static Music_iterator
* static_get_iterator_p (Music
* mus
);
82 void init_translator (Music
*, Translator_group
*);
84 virtual Moment
pending_moment () const;
85 virtual bool ok () const;
86 virtual SCM
get_music (Moment until
)const;
87 virtual void process (Moment until
);
88 virtual void skip (Moment until
);
91 Construct sub-iterators, and set the translator to
94 virtual void construct_children ();
95 static SCM constructor_cxx_function
;
98 Get an iterator for MUS, inheriting the translation unit from THIS.
100 Music_iterator
* get_iterator_p (Music
*) const;
102 virtual Music_iterator
* try_music_in_children (Music
*) const;
104 Music
* music_l () const;
106 Interpretation_context_handle handle_
;
112 implement Class::constructor, a SCM function that
113 returns an encapsulated factory function.
115 #define IMPLEMENT_CTOR_CALLBACK(Class) \
117 Class ## _ctor (SCM) \
121 SCM Class :: constructor_cxx_function;\
123 Class ## _constructor_init () \
125 SCM s = smobify_cxx_function (& Class ## _ctor); \
126 scm_permanent_object (s);\
127 gh_define (#Class "::constructor", s);\
128 Class :: constructor_cxx_function = s;\
130 ADD_SCM_INIT_FUNC (Class ## _ctor_init, Class ## _constructor_init);
138 #endif // MUSIC_ITERATOR_HH