]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator.cc
patch::: 1.3.18.jcn1
[lilypond.git] / lily / translator.cc
1 /*
2   translator.cc -- implement 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 "translator.hh"
10 #include "debug.hh"
11 #include "translator-group.hh"
12 #include "moment.hh"
13
14 char const*
15 Translator::name() const
16 {
17   return classname(this);
18 }
19
20 Translator::~Translator ()
21 {
22 }
23
24 Translator::Translator ()
25 {
26   status = ORPHAN;
27   daddy_trans_l_ = 0;
28   output_def_l_ = 0;
29 }
30
31 Translator::Translator (Translator const &s)
32   : Input (s)
33 {
34   status = ORPHAN;
35   daddy_trans_l_ =0;
36   output_def_l_ = s.output_def_l_;
37   type_str_ = s.type_str_;
38 }
39
40 bool
41 Translator::is_alias_b (String s) const
42 {
43   return s == type_str_;
44 }
45
46 bool
47 Translator::do_try_music (Music *)
48 {
49   return false;
50 }
51                             
52
53 Moment
54 Translator::now_mom () const
55 {
56   return daddy_trans_l_->now_mom ();
57 }
58
59
60 void
61 Translator::add_processing ()
62 {
63   if (status > ORPHAN)
64     return;
65   
66   do_add_processing ();
67   status = VIRGIN;
68 }
69
70 void
71 Translator::do_add_processing ()
72 {
73 }
74
75 void
76 Translator::print () const
77 {
78 #ifndef NPRINT
79   DEBUG_OUT << classname (this) << " {";
80   if (classname (this) != type_str_)
81     DEBUG_OUT << "type = " << type_str_;
82   do_print ();
83   DEBUG_OUT << "}\n";
84 #endif
85 }
86
87 void
88 Translator::do_print () const
89 {
90 }
91
92
93
94
95 void
96 Translator::creation_processing ()
97 {
98   if (status >= CREATION_INITED)
99     return ;
100   
101   do_creation_processing ();
102   status = CREATION_INITED;
103 }
104
105 void
106 Translator::post_move_processing ()
107 {
108   if (status >= MOVE_INITED)
109     return;
110
111   creation_processing ();
112   do_post_move_processing ();
113   status = MOVE_INITED;
114 }
115
116 void
117 Translator::removal_processing ()
118 {
119   if (status == ORPHAN)
120     return;
121   creation_processing ();
122   do_removal_processing ();
123   // elegancy ...
124   // status = ORPHAN;
125 }
126
127
128 bool
129 Translator::try_music (Music * r)
130 {
131   if (status < MOVE_INITED)
132     post_move_processing ();
133
134   return do_try_music (r);
135 }
136
137 void
138 Translator::process_requests ()
139 {
140   if (status < PROCESSED_REQS)
141     post_move_processing ();
142   else if (status >= PROCESSED_REQS)
143     return; 
144   
145   status = PROCESSED_REQS;
146   do_process_requests ();
147 }
148
149 void
150 Translator::pre_move_processing ()
151 {
152   do_pre_move_processing ();
153   status = CREATION_INITED;
154 }
155
156
157
158 Music_output_def *
159 Translator::output_def_l () const
160 {
161   return output_def_l_;
162 }
163
164 SCM
165 Translator::get_property (String id, Translator_group **where_l) const
166 {
167   return daddy_trans_l_->get_property (ly_symbol2scm (id.ch_C()), where_l);
168 }
169
170 SCM
171 Translator::get_property (SCM sym,
172                           Translator_group **where_l) const
173 {
174   return daddy_trans_l_->get_property (sym, where_l);
175 }
176
177
178
179 void
180 Translator:: do_pre_move_processing(){}
181 void
182 Translator::do_post_move_processing(){}
183 void
184 Translator::do_process_requests () {}
185 void
186 Translator::do_creation_processing() {}
187 void
188 Translator::do_removal_processing(){}