]> git.donarmstrong.com Git - lilypond.git/blob - lily/chord-iterator.cc
release: 0.1.11
[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 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "translator.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());  //, int j = 0; 
30        i.ok(); j++, i++) 
31     {
32       Music_iterator * mi =  get_iterator_p (i.ptr());
33       if (mi->ok()) 
34         {
35           set_translator (mi->report_to_l()->ancestor_l (chord_C_->multi_level_i_));
36           children_p_list_.bottom().add (mi);
37         }
38       else 
39         delete mi;
40     }
41 }
42 void
43 Chord_iterator::do_print() const
44 {
45 #ifndef NPRINT
46   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++) 
47     {
48       i->print();
49     }
50 #endif
51 }
52
53 void
54 Chord_iterator::process_and_next (Moment until)
55 {
56   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok ();) 
57     {
58       if  (i->next_moment() == until) 
59         {
60           i->process_and_next (until);
61         }
62       if (!i->ok()) 
63         delete i.remove_p();
64       else
65         i++;
66     }
67   Music_iterator::process_and_next (until);
68 }
69
70
71 IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator);
72
73 Moment
74 Chord_iterator::next_moment() const
75 {
76   Moment next_ = infinity_mom;
77   for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
78     next_ = next_ <? i->next_moment() ;
79   return next_;
80 }
81
82
83
84 bool
85 Chord_iterator::ok() const
86 {
87   return children_p_list_.size();
88 }