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