lilypond-1.3.65
[lilypond.git] / lily / command-request.cc
blob92143f8a5554482515790b60b4a088bb21ad7870
1 /*
2 command-request.cc -- implement non-musical reqs
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "command-request.hh"
10 #include "debug.hh"
11 #include "musical-request.hh"
14 bool
15 Bar_req::do_equal_b (Request const *r) const
17 Bar_req const* b = dynamic_cast <Bar_req const *> (r);
18 return b && type_str_ == b->type_str_;
21 void
22 Bar_req::do_print () const
24 #ifndef NPRINT
25 DEBUG_OUT << type_str_;
26 #endif
29 Bar_req::Bar_req (String s)
31 type_str_ = s;
34 bool
35 Barcheck_req::do_equal_b (Request const *r) const
37 Barcheck_req const*b = dynamic_cast<Barcheck_req const*> (r);
38 return b;
41 void
42 Clef_change_req::do_print () const
44 #ifndef NPRINT
45 DEBUG_OUT << clef_str_ ;
46 #endif
49 Clef_change_req::Clef_change_req (String s)
51 clef_str_ = s;
55 void
56 Time_signature_change_req::do_print () const
58 #ifndef NPRINT
59 DEBUG_OUT << beats_i_ << "/" << one_beat_i_;
60 #endif
63 bool
64 Time_signature_change_req::do_equal_b (Request const *r) const
66 Time_signature_change_req const* m
67 = dynamic_cast <Time_signature_change_req const*> (r);
69 return m && m->beats_i_ == beats_i_
70 && one_beat_i_ == m->one_beat_i_;
73 Time_signature_change_req::Time_signature_change_req ()
75 beats_i_ = 0;
76 one_beat_i_ =0;
80 Tempo_req::Tempo_req ()
82 metronome_i_ = 60;
83 dur_. durlog_i_ = 2;
86 void
87 Tempo_req::do_print () const
89 DEBUG_OUT << dur_.str () << " = " << metronome_i_;
93 bool
94 Tempo_req::do_equal_b (Request const *r) const
96 Tempo_req const *t = dynamic_cast <Tempo_req const*> (r);
98 return t&& t->dur_.length_mom ()== dur_.length_mom () && metronome_i_ == t->metronome_i_;
104 bool
105 Key_change_req::do_equal_b (Request const * req) const
107 Key_change_req const * k = dynamic_cast<Key_change_req const*> (req);
108 return k && scm_equal_p (pitch_alist_, k->pitch_alist_);
113 void
114 Key_change_req::transpose (Musical_pitch p)
116 SCM newlist = SCM_EOL;
117 for (SCM s = pitch_alist_; gh_pair_p (s); s = gh_cdr (s))
119 SCM k = gh_caar (s);
121 if (gh_pair_p (k))
123 Musical_pitch orig (gh_list (gh_car (k), gh_cdr (k), gh_cdr (s), SCM_UNDEFINED));
125 orig.transpose (p);
127 SCM key = gh_cons (gh_int2scm (orig.octave_i_),
128 gh_int2scm (orig.notename_i_));
130 newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
131 newlist);
133 else if (gh_number_p (k))
135 Musical_pitch orig (gh_list (gh_int2scm (0), k, gh_cdar (s), SCM_UNDEFINED));
136 orig.transpose (p);
138 SCM key =gh_int2scm (orig.notename_i_);
139 newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
140 newlist);
144 pitch_alist_ = newlist;
147 Break_req::Break_req ()
153 bool
154 Mark_req::do_equal_b (Request const * r) const
156 Mark_req const * other = dynamic_cast<Mark_req const*> (r);
157 return other && scm_equal_p (other->mark_label_, mark_label_);