]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/command-request.hh
release: 0.1.49
[lilypond.git] / lily / include / command-request.hh
1 /*
2   command-request.hh -- declare non-musical requests
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef COMMANDREQUEST_HH
11 #define COMMANDREQUEST_HH
12
13 #include "request.hh"
14 #include "varray.hh"
15 #include "duration.hh"
16
17 /** Request which are  assumed to be "happening" before the
18   musical requests. */
19 class Command_req  : public virtual Request  {
20 public:
21   REQUESTMETHODS(Command_req, command);
22   virtual Measure_grouping_req * measuregrouping() { return 0; }
23   virtual Clef_change_req * clefchange() { return 0; }
24   virtual Key_change_req * keychange() { return 0; }
25   virtual Partial_measure_req * partial() { return 0; }
26   virtual Meter_change_req * meterchange() { return 0; }
27   virtual Bar_req *bar() { return 0; }
28   virtual Cadenza_req *cadenza() { return 0; }
29   virtual Disallow_break_req *disallowbreak() { return 0; }
30   virtual Timing_req*timing() {  return 0; }
31   virtual Command_script_req*commandscript() { return 0;}
32   virtual Break_force_req *forcebreak () { return 0; }
33 };
34
35
36 class Break_force_req : public Command_req {
37 public:
38   REQUESTMETHODS(Break_force_req, forcebreak);
39 };
40
41 class Command_script_req : public Command_req,  public Script_req {
42 public:
43   // huh? 
44   Command_script_req();
45   ~Command_script_req();
46   REQUESTMETHODS(Command_script_req, commandscript);
47 };
48
49
50 class Disallow_break_req : public Command_req {
51 public:
52   REQUESTMETHODS(Disallow_break_req, disallowbreak);
53 };
54
55
56 /** Baseclass for meter/partial req. It has to be handled by
57   Staff_{walker,column} baseclass.  */
58 class Timing_req  : public Command_req  {
59 public:
60   REQUESTMETHODS(Timing_req, timing);
61   virtual Tempo_req * tempo(){return 0; }
62 };
63
64
65 class Tempo_req : public Timing_req
66 {
67 public:
68   Duration dur_;
69   int metronome_i_;
70
71   Tempo_req();
72   REQUESTMETHODS(Tempo_req, tempo);
73   bool do_equal_b (Request *) const;
74 };
75
76 class Partial_measure_req  : public Timing_req  {
77 public:
78   Moment duration_;
79
80   Partial_measure_req (Moment);
81   REQUESTMETHODS(Partial_measure_req, partial);
82   bool do_equal_b (Request*) const;
83 };
84
85 /**
86   todo: allow C meter
87  */
88 class Meter_change_req  : public Timing_req  {
89 public:
90   int beats_i_, one_beat_i_;
91
92   Meter_change_req();
93   void set (int,int);
94   bool do_equal_b (Request*) const;
95   REQUESTMETHODS(Meter_change_req, meterchange);
96 };
97
98 /// toggle Cadenza mode
99 class Cadenza_req  : public Timing_req  {
100 public:
101   /// turn on?
102   bool on_b_;
103   bool do_equal_b (Request*) const;
104   Cadenza_req (bool);
105   REQUESTMETHODS(Cadenza_req,cadenza);
106 };
107
108 /// check if we're at start of a  measure.
109 class Barcheck_req  : public Timing_req  {
110 public:
111   bool do_equal_b (Request *) const;
112   REQUESTMETHODS(Barcheck_req,barcheck);
113 };
114
115 class Measure_grouping_req : public Timing_req  {
116 public:
117   Array<int> beat_i_arr_;
118   Array<Moment> elt_length_arr_;
119   bool do_equal_b (Request *) const;
120   REQUESTMETHODS(Measure_grouping_req, measuregrouping);
121 };
122
123 /** draw a (repeat)-bar. This something different than #Barcheck_req#,
124   the latter should only happen at the start of a measure.  */
125 class Bar_req  : public Command_req  {
126 public:
127   String type_str_;
128   Bar_req (String);
129   bool do_equal_b (Request*) const;
130
131   REQUESTMETHODS(Bar_req,bar);
132 };
133
134
135 /**
136     Handle key changes.
137     Routines for sharps and flats are separated, 
138     so that caller may identify non-conventional keys.
139 */
140 class Key_change_req  : public Command_req  {
141 public:
142   Array<Melodic_req*> melodic_p_arr_;
143   bool minor_b_;
144
145   /// don't ignore the  octaves in #melodic_p_arr_#?
146   bool multi_octave_b_;
147   Key_change_req();
148   Key_change_req (Key_change_req const&);
149   ~Key_change_req();
150   REQUESTMETHODS(Key_change_req, keychange);
151
152   /// squash the octaves to 1
153   void squash_octaves();
154   /// return number of flats in key
155   int flats_i();
156
157   /// return number of sharps in key
158   int sharps_i();
159
160   void transpose (Melodic_req const * d) const;
161   /// is minor key?
162   int minor_b();
163 };
164
165 class Clef_change_req  : public Command_req  {
166 public:
167   String clef_str_;
168   Clef_change_req (String);
169   REQUESTMETHODS(Clef_change_req, clefchange);
170 };
171
172 #endif // COMMANDREQUEST_HH