1 #include "inputcommands.hh"
2 #include "inputcommand.hh"
4 #include "staffcommands.hh"
5 #include "getcommand.hh"
13 Commands_at::print() const
16 mtor
<< "Commands_at {";
17 tdescription_
.print();
18 for (iter_top(*this,cc
); cc
.ok(); cc
++)
27 return tdescription_
.when
;
30 Commands_at::Commands_at(Moment dt
, Commands_at
* prev
)
31 : tdescription_(dt
, (prev
)? &prev
->tdescription_
: 0)
33 if (prev
&& !tdescription_
.whole_in_measure
) {
34 bottom().add(get_newmeasure_command());
39 Commands_at::add(Input_command
*i
)
43 // should check for other meterchanges here.
44 if (i
->args
[0] == "METER") {
47 tdescription_
.set_meter(l
,o
);
48 bottom().add(get_grouping_command( get_default_grouping(l
,o
)));
52 Commands_at::Commands_at(Commands_at
const&src
) :
53 tdescription_(src
.tdescription_
)
55 IPointerList
<Input_command
*> &me(*this);
56 const IPointerList
<Input_command
*> &that(src
);
62 Commands_at::setpartial(Moment p
)
64 tdescription_
.setpartial(p
);
68 Commands_at::barleft()
70 return tdescription_
.barleft();
74 Commands_at::parse(Staff_commands_at
*s
)
76 s
->tdescription_
= tdescription_
;
77 for (iter_top(*this,cc
); cc
.ok(); cc
++) {
78 if (cc
->args
.size() && cc
->args
[0] !="") {
88 Input_cursor::find_moment(Moment w
)
93 *this = list().bottom();
95 Moment dt
= (w
- when());
96 if ( !ptr()->tdescription_
.cadenza_b_
)
97 dt
= dt
<? ptr()->barleft();
99 Commands_at
* c
= new Commands_at(dt
, *this);
100 assert(c
->when() <= w
);
102 } else if (when() == w
) {
104 } else if (when() > w
)
113 Moment dt
= (w
- when());
114 Commands_at
* c
= new Commands_at(dt
, *this);
121 /* *************** */
123 Input_commands::find_moment(Moment m
)
128 Input_commands::Input_commands(Input_commands
const&src
)
131 IPointerList
<Commands_at
*> &me(*this);
132 const IPointerList
<Commands_at
*> &that(src
);
137 Input_commands::Input_commands()
140 Commands_at
* p
= new Commands_at(0,0);
146 Input_commands::do_skip(int bars
, Moment wholes
)
149 Moment b
= ptr
->barleft();
150 ptr
.find_moment(ptr
->when() + b
);
154 ptr
.find_moment(ptr
->when() + wholes
);
160 Input_commands::add(Input_command c
, Assoc
<String
,Moment
> &marks_assoc_r
)
163 if (s
== "CADENZA") {
164 ptr
->tdescription_
.set_cadenza((int)c
.args
[1]);
165 } if (s
== "PARTIAL") {
166 ptr
->setpartial(c
.args
[1]);
167 } else if (s
== "GROUPING") {
168 Input_command
*ic
= new Input_command(c
);
169 ic
->args
.insert(ptr
->tdescription_
.one_beat
, 1);
171 } else if (s
== "METER") {
172 int beats_per_meas
= c
.args
[1];
173 int one_beat
= c
.args
[2];
174 Input_command
*ch
= get_meterchange_command(beats_per_meas
, one_beat
);
176 } else if (s
== "SKIP") {
177 int bars
= c
.args
[1] ;
178 Moment wholes
= c
.args
[2];
179 do_skip(bars
, wholes
);
180 } else if (s
== "RESET") {
182 } else if (s
=="GOTO") {
185 if (!marks_assoc_r
.elt_query(m
)) {
186 warning( "Unknown marker: `" +m
+ "\'", 0 );
190 ptr
.find_moment(marks_assoc_r
[m
]);
192 Input_command
*ic
= new Input_command(c
);
199 Input_commands::parse(Staff
* staff_l
) const
202 for (iter_top(*this,i
); i
.ok(); i
++) {
204 Staff_column
* col_l
= staff_l
->get_col(i
->when(), false);
205 if (!col_l
->staff_commands_p_
)
206 col_l
->staff_commands_p_
= new Staff_commands_at(i
->tdescription_
);
208 Staff_commands_at
* com_l
= col_l
->staff_commands_p_
;
210 if (!i
->when()) { /* all pieces should start with a breakable. */
211 com_l
->set_breakable();
220 Input_commands::print() const
223 for (iter_top(*this,cc
); cc
.ok() ; cc
++) {
228 /* *************** */
231 Input_cursor::when()const
233 return (*this)->when();
235 Input_cursor::Input_cursor(PCursor
<Commands_at
*>c
)
236 : PCursor
<Commands_at
*>(c
)