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