]> git.donarmstrong.com Git - lilypond.git/blob - src/request.cc
release: 0.0.24
[lilypond.git] / src / request.cc
1 #include "request.hh"
2 #include "misc.hh"
3 #include "debug.hh"
4 #include "scriptdef.hh"
5 #include "textdef.hh"
6
7 #include "inputcommand.hh"
8
9 #define VIRTUALCONS(T,R) R *T::clone() const { return  new T(*this); } struct T
10 #define RCONS(T) VIRTUALCONS(T, Request)
11
12 RCONS(Rest_req);
13 RCONS(Barcheck_req);
14 RCONS(Text_req);
15 RCONS(Rhythmic_req);
16 RCONS(Lyric_req);
17 RCONS(Mark_req);
18 RCONS(Stem_req);
19 RCONS(Script_req);
20 RCONS(Note_req);
21 RCONS(Melodic_req);
22 RCONS(Span_req);
23 RCONS(Slur_req);
24 RCONS(Beam_req);
25 RCONS(Staff_command_req);
26
27 void
28 Stem_req::print() const
29 {
30     mtor << "Stem\n";
31 }
32 /****************/
33 void
34 Barcheck_req::print() const    
35 {
36 #ifndef NPRINT
37     mtor << "Barcheck\n";
38 #endif
39 }
40 /****************/
41 void
42 Request::print() const    
43 {
44 #ifndef NPRINT
45     mtor << "Req{ unknown }\n";
46 #endif
47 }
48
49 void
50 Span_req::print() const    
51 {
52 #ifndef NPRINT
53     mtor << "Span_req {" << spantype << "}\n";
54 #endif
55 }
56
57 Request::Request()
58 {
59     elt_l_ = 0;
60 }
61 Request::Request(Request const&)
62 {
63     elt_l_ = 0;
64 }
65 /****************/
66 Melodic_req::Melodic_req()
67 {
68     name = 0;
69     octave = 0;
70     accidental = 0;
71     forceacc = false;
72 }
73
74 void
75 Melodic_req::print() const
76 {
77     mtor << "note: " << name << " oct: "<< octave;
78 }
79
80 int
81 Melodic_req::height() const
82 {
83     return  name + octave*7;
84 }
85
86 /****************/
87 Rhythmic_req::Rhythmic_req()
88 {
89     plet_factor = 1;
90     balltype = 1;
91     dots = 0;
92 }
93
94 void
95 Rhythmic_req::print() const
96 {
97     mtor << "rhythmic: " << balltype ;
98     int d =dots;
99     while (d--)
100         mtor << '.';
101     
102     mtor<<", plet factor"<<plet_factor<<"\n";
103 }
104
105
106 Moment
107 Rhythmic_req::duration() const {    
108     return wholes(balltype,dots)*plet_factor;
109 }
110 /****************/
111
112 Lyric_req::Lyric_req(Text_def* def_p)
113     :Text_req(0, def_p)
114 {
115     def_p->align_i_ = 1;        // raggedright
116     dir_i_ = -1;                // lyrics below (invisible) staff
117 }
118
119 void
120 Lyric_req::print() const
121 {
122     mtor << "lyric: ";
123     Rhythmic_req::print();
124     Text_req::print();
125 }
126 /****************/
127 void
128 Note_req::print() const
129 {
130     Melodic_req::print();
131     Rhythmic_req::print();
132 }
133 /****************/
134 void
135 Rest_req::print() const
136 {
137     mtor << "rest, " ;
138     Rhythmic_req::print();
139 }
140 /****************/
141 Beam_req::Beam_req()
142 {
143     nplet = 0;
144 }
145 /****************/
146 Span_req::Span_req()
147 {
148     spantype = NOSPAN;
149 }
150 /****************/
151 Script_req::Script_req(int d , Script_def*def)
152 {
153     dir = d;
154     scriptdef = def;
155 }
156
157 Script_req::Script_req(Script_req const &s)
158 {
159     dir = s.dir;
160     scriptdef = new Script_def(*s.scriptdef);
161 }
162
163 void
164 Script_req::print() const
165 {
166     mtor << " dir " << dir ;
167     scriptdef->print();
168 }
169
170
171 Script_req::~Script_req()
172 {
173     delete scriptdef;
174 }
175 /****************/
176
177 Text_req::~Text_req()
178 {
179     delete tdef_p_;
180     tdef_p_ = 0;
181 }
182
183 Text_req::Text_req(Text_req const& src)
184 {
185     tdef_p_ = new Text_def(*src.tdef_p_);
186     dir_i_ = src.dir_i_;
187 }
188
189 Text_req::Text_req(int dir_i, Text_def* tdef_p) 
190 {
191     dir_i_ = dir_i;
192     tdef_p_ = tdef_p;
193 }
194
195 void
196 Text_req::print() const
197 {
198     mtor << " dir " << dir_i_ ;
199     tdef_p_->print();
200 }
201
202
203
204 /****************/
205
206 Mark_req::Mark_req(String s)
207 {
208     mark_str_ = s;
209 }
210
211 void
212 Mark_req::print()const
213 {
214 #ifndef NDEBUG
215     mtor<< "Mark `" << mark_str_ << "\'\n";
216 #endif
217 }
218 /****************/
219 Staff_command_req::Staff_command_req(Input_command * p)
220 {
221     com_p_ = p;
222 }
223 Staff_command_req::~Staff_command_req()
224 {
225     delete com_p_;
226 }
227 Staff_command_req::Staff_command_req(Staff_command_req const&src)
228 {
229     com_p_ = new Input_command(*src.com_p_);
230 }
231 void
232 Staff_command_req::print()const
233 {
234     mtor << "Command request: " ;
235     com_p_->print();
236 }
237
238