]> git.donarmstrong.com Git - lilypond.git/blob - lily/global-translator.cc
aa7178f0796d50ff6fae54f2c3c49686e86571f2
[lilypond.git] / lily / global-translator.cc
1 /*
2   global-translator.cc -- implement Global_translator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "global-translator.hh"
10 #include "music-iterator.hh"
11 #include "debug.hh"
12
13 Global_translator::Global_translator()
14 {
15   last_mom_ = 0;
16 }
17
18 void
19 Global_translator::add_moment_to_process (Moment m)
20 {
21   if (m  > last_mom_)
22     return;
23   
24   for (int i=0; i <  extra_mom_pq_.size(); i++)
25     if (extra_mom_pq_[i] == m)
26       return;
27   extra_mom_pq_.insert (m);
28 }
29
30 void
31 Global_translator::modify_next (Moment &w)
32 {
33   while (extra_mom_pq_.size() && 
34          extra_mom_pq_.front() <= w)
35         
36     w =extra_mom_pq_.get();
37 }
38
39 int
40 Global_translator::moments_left_i() const
41 {
42   return extra_mom_pq_.size();
43 }
44
45 void
46 Global_translator::prepare (Moment m)
47 {
48   now_mom_ = m;
49 }
50
51 Moment
52 Global_translator::now_mom () const
53 {
54   return now_mom_;
55 }
56
57
58
59 Music_output*
60 Global_translator::get_output_p()
61 {
62   return 0;
63 }
64
65 void
66 Global_translator::process ()
67 {
68 }
69 void
70 Global_translator::start ()
71 {
72 }
73 void
74 Global_translator::finish ()
75 {
76 }
77
78 void
79 Global_translator::run_iterator_on_me (Music_iterator * iter)
80 {
81   while (iter->ok() || moments_left_i ())
82     {
83       Moment w;
84       w.set_infinite (1);
85       if (iter->ok())
86         {
87           w = iter->next_moment();
88           DOUT << "proccing: " << w << '\n';
89           if (!monitor->silent_b ("walking"))
90             iter->print();
91         }
92       
93       modify_next (w);
94       prepare (w);
95       
96       if (!monitor->silent_b ("walking"))
97         print();
98
99       iter->process_and_next (w);
100       process();
101     }
102 }