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