lilypond-1.5.9
[lilypond.git] / lily / global-translator.cc
blobd66b6f05e9b439fbe67bca93d2a060b3e111ffa0
1 /*
2 global-translator.cc -- implement Global_translator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
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"
16 Global_translator::Global_translator ()
20 void
21 Global_translator::add_moment_to_process (Moment m)
23 if (m > final_mom_)
24 return;
26 if (m < now_mom_)
27 programming_error ("Trying to freeze in time.");
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);
35 Moment
36 Global_translator::sneaky_insert_extra_moment (Moment w)
38 while (extra_mom_pq_.size () && extra_mom_pq_.front () <= w)
39 w = extra_mom_pq_.get ();
40 return w;
43 int
44 Global_translator::moments_left_i () const
46 return extra_mom_pq_.size ();
49 void
50 Global_translator::prepare (Moment m)
52 prev_mom_ = now_mom_;
53 now_mom_ = m;
56 Moment
57 Global_translator::now_mom () const
59 return now_mom_;
64 Music_output*
65 Global_translator::get_output_p ()
67 return 0;
70 void
71 Global_translator::one_time_step ()
74 void
75 Global_translator::start ()
78 void
79 Global_translator::finish ()
83 void
84 Global_translator::run_iterator_on_me (Music_iterator * iter)
86 if (iter-> ok ())
87 prev_mom_ = now_mom_ = iter->pending_moment ();
89 bool first = true;
90 while (iter->ok () || moments_left_i ())
92 Moment w;
93 w.set_infinite (1);
94 if (iter->ok ())
96 w = iter->pending_moment ();
99 w = sneaky_insert_extra_moment (w);
101 cout << "Proccing " << w << endl;
104 if (first)
106 first = false;
107 set_property (ly_symbol2scm ("measurePosition"), w.smobbed_copy ());
110 prepare (w);
111 if (iter->ok ())
112 iter->process (w);
114 one_time_step ();