]> git.donarmstrong.com Git - lilypond.git/blob - lily/chord-iterator.cc
777a9bcb4431e59ca2da1c23035733fa8337f14a
[lilypond.git] / lily / chord-iterator.cc
1 /*
2   chord-iter.cc -- implement Chord_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "translator-group.hh"
10 #include "debug.hh"
11 #include "chord-iterator.hh"
12
13 #include "music-list.hh"
14
15
16 Chord_iterator::~Chord_iterator()
17 {
18 }
19
20 Chord_iterator::Chord_iterator (Chord const *chord_C)
21 {
22   chord_C_ = chord_C;
23 }
24
25 void
26 Chord_iterator::construct_children()
27 {
28   int j = 0;
29   for (PCursor<Music*> i (chord_C_->music_p_list_.top());  
30        i.ok(); j++, i++) 
31     {
32       Music_iterator * mi = get_iterator_p (i.ptr());
33       if (mi->ok()) 
34         {
35           if  (chord_C_->translator_type_str_.empty_b ())
36             set_translator (mi->report_to_l()->ancestor_l (chord_C_->multi_level_i_));
37           children_p_list_.bottom().add (mi);
38         }
39       else 
40         delete mi;
41     }
42 }
43
44
45 void
46 Chord_iterator::do_print() const
47 {
48 #ifndef NPRINT
49   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++) 
50     {
51       i->print();
52     }
53 #endif
54 }
55
56 void
57 Chord_iterator::process_and_next (Moment until)
58 {
59   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok ();) 
60     {
61       if  (i->next_moment() == until) 
62         {
63           i->process_and_next (until);
64         }
65       if (!i->ok()) 
66         delete i.remove_p();
67       else
68         i++;
69     }
70   Music_iterator::process_and_next (until);
71 }
72
73
74 IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator);
75
76 Moment
77 Chord_iterator::next_moment() const
78 {
79   Moment next;
80   next.set_infinite (1);
81   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
82     next = next <? i->next_moment() ;
83   return next;
84 }
85
86
87
88 bool
89 Chord_iterator::ok() const
90 {
91   return children_p_list_.size();
92 }