lilypond-1.1.21
[lilypond.git] / lily / chord-iterator.cc
blob1f61364c2b98d6f0933613086f28a0403874ba47
1 /*
2 Simultaneous_music-iter.cc -- implement Simultaneous_music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "translator-group.hh"
10 #include "debug.hh"
11 #include "chord-iterator.hh"
13 #include "music-list.hh"
16 void
17 Simultaneous_music_iterator::construct_children()
19 int j = 0;
20 for (PCursor<Music*> i (simultaneous_music_l ()->music_p_list_p_->top());
21 i.ok(); j++, i++)
23 Music_iterator * mi = get_iterator_p (i.ptr());
24 if (mi->ok())
26 if (simultaneous_music_l ()->translator_type_str_.empty_b ())
27 set_translator (mi->report_to_l()->ancestor_l (0));
28 children_p_list_.bottom().add (mi);
30 else
31 delete mi;
36 void
37 Simultaneous_music_iterator::do_print() const
39 #ifndef NPRINT
40 for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
42 i->print();
44 #endif
47 void
48 Simultaneous_music_iterator::do_process_and_next (Moment until)
50 for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok ();)
52 if (i->next_moment() == until)
54 i->process_and_next (until);
56 if (!i->ok())
57 delete i.remove_p();
58 else
59 i++;
61 Music_iterator::do_process_and_next (until);
67 Moment
68 Simultaneous_music_iterator::next_moment() const
70 Moment next;
71 next.set_infinite (1);
72 for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
73 next = next <? i->next_moment() ;
74 return next;
79 bool
80 Simultaneous_music_iterator::ok() const
82 return children_p_list_.size();
85 Simultaneous_music*
86 Simultaneous_music_iterator::simultaneous_music_l ()const
88 return ( Simultaneous_music *) music_l_;