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