2 voice-iter.cc -- implement Voice_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "translator.hh"
11 #include "voice-iterator.hh"
12 #include "music-list.hh"
16 Voice_iterator::do_print() const
22 Voice_iterator::Voice_iterator (Voice
const*v
)
23 : PCursor
<Music
*> (v
->music_p_list_
)
25 here_mom_
= v
->offset_mom_
;
31 Voice_iterator::construct_children()
33 while (PCursor
<Music
*>::ok())
42 set_voice_translator();
49 Voice_iterator::leave_element()
53 MInterval elt_time
= ptr()->time_int ();
54 if (!elt_time
.empty_b())
55 here_mom_
+= elt_time
.length();
56 PCursor
<Music
*>::next();
60 Voice_iterator::start_next_element()
63 iter_p_
= get_iterator_p (ptr());
67 Voice_iterator::set_voice_translator()
69 if (iter_p_
->report_to_l()->depth_i () > report_to_l ()->depth_i ())
70 set_translator (iter_p_
->report_to_l());
73 Voice_iterator::~Voice_iterator()
79 IMPLEMENT_IS_TYPE_B1(Voice_iterator
,Music_iterator
);
82 Voice_iterator::process_and_next (Moment until
)
86 Moment local_until
= until
- here_mom_
;
89 Moment here
= iter_p_
->next_moment();
90 if (here
!= local_until
)
93 iter_p_
->process_and_next (local_until
);
100 if (PCursor
<Music
*>::ok())
102 start_next_element();
103 set_voice_translator();
114 Music_iterator::process_and_next (until
);
118 Voice_iterator::next_moment() const
120 return iter_p_
->next_moment() + here_mom_
;
124 Voice_iterator::ok() const