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