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