]> git.donarmstrong.com Git - lilypond.git/blob - lily/chord-iterator.cc
release: 0.1.61
[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@stack.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 void
44 Chord_iterator::do_print() const
45 {
46 #ifndef NPRINT
47   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++) 
48     {
49       i->print();
50     }
51 #endif
52 }
53
54 void
55 Chord_iterator::process_and_next (Moment until)
56 {
57   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok ();) 
58     {
59       if  (i->next_moment() == until) 
60         {
61           i->process_and_next (until);
62         }
63       if (!i->ok()) 
64         delete i.remove_p();
65       else
66         i++;
67     }
68   Music_iterator::process_and_next (until);
69 }
70
71
72 IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator);
73
74 Moment
75 Chord_iterator::next_moment() const
76 {
77   Moment next;
78   next.set_infinite (1);
79   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
80     next = next <? i->next_moment() ;
81   return next;
82 }
83
84
85
86 bool
87 Chord_iterator::ok() const
88 {
89   return children_p_list_.size();
90 }