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