]> git.donarmstrong.com Git - lilypond.git/blob - lily/global-translator.cc
1713ce373637844343ec828a977c3c9b08e7d7b1
[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--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "debug.hh"
10 #include "music.hh"
11 #include "request.hh"
12 #include "music-list.hh"
13 #include "music-iterator.hh"
14 #include "global-translator.hh"
15
16 Global_translator::Global_translator ()
17 {
18 }
19
20 void
21 Global_translator::add_moment_to_process (Moment m)
22 {
23   if (m  > final_mom_)
24     return;
25
26   if (m < now_mom_ )
27     programming_error ("Trying to freeze in time.");
28   
29   for (int i=0; i <  extra_mom_pq_.size(); i++)
30     if (extra_mom_pq_[i] == m)
31       return;
32   extra_mom_pq_.insert (m);
33 }
34
35 Moment
36 Global_translator::sneaky_insert_extra_moment (Moment w)
37 {
38   while (extra_mom_pq_.size() && extra_mom_pq_.front() <= w)
39     w = extra_mom_pq_.get();
40   return w;
41 }
42
43 int
44 Global_translator::moments_left_i() const
45 {
46   return extra_mom_pq_.size();
47 }
48
49 void
50 Global_translator::prepare (Moment m)
51 {
52   prev_mom_  = now_mom_;
53   now_mom_ = m;
54 }
55
56 Moment
57 Global_translator::now_mom () const
58 {
59   return now_mom_;
60 }
61
62
63
64 Music_output*
65 Global_translator::get_output_p()
66 {
67   return 0;
68 }
69
70 void
71 Global_translator::process ()
72 {
73 }
74 void
75 Global_translator::start ()
76 {
77 }
78 void
79 Global_translator::finish ()
80 {
81 }
82
83 void
84 Global_translator::run_iterator_on_me (Music_iterator * iter)
85 {
86
87   while (iter->ok () || moments_left_i ())
88     {
89       Moment w;
90       w.set_infinite (1);
91       if (iter->ok ())
92         {
93           w = iter->pending_moment();
94       
95           DEBUG_OUT << "proccing: " << w << '\n';
96         }
97
98       w = sneaky_insert_extra_moment (w);
99       prepare (w);
100       iter->process (w);
101       
102       process ();
103     }
104 }