1 #include "inputcommands.hh"
2 #include "inputcommand.hh"
4 #include "staffcommands.hh"
5 #include "getcommand.hh"
12 Commands_at::print() const
15 mtor << "Commands_at {";
16 tdescription_.print();
17 for (iter_top(*this,cc); cc.ok(); cc++)
26 return tdescription_.when;
29 Commands_at::Commands_at(Moment dt, Commands_at* prev)
30 : tdescription_(dt, (prev)? &prev->tdescription_ : 0)
32 if (prev && !tdescription_.whole_in_measure) {
33 bottom().add(get_newmeasure_command());
38 Commands_at::add(Input_command *i)
42 // should check for other meterchanges here.
43 if (i->args[0] == "METER") {
46 tdescription_.set_meter(l,o);
47 bottom().add(get_grouping_command( get_default_grouping(l)));
51 Commands_at::Commands_at(Commands_at const&src) :
52 tdescription_(src.tdescription_)
54 IPointerList<Input_command*> &me(*this);
55 const IPointerList<Input_command*> &that(src);
61 Commands_at::setpartial(Moment p)
63 tdescription_.setpartial(p);
67 Commands_at::barleft()
69 return tdescription_.barleft();
73 Commands_at::parse(Staff_commands_at*s)
75 s->tdescription_ = tdescription_;
76 for (iter_top(*this,cc); cc.ok(); cc++) {
77 if (cc->args.size() && cc->args[0] !="") {
87 Input_cursor::find_moment(Moment w)
92 *this = list().bottom();
94 Moment dt = (w - when());
95 if ( !ptr()->tdescription_.cadenza_b_ )
96 dt = dt <? ptr()->barleft();
98 Commands_at * c = new Commands_at(dt, *this);
99 assert(c->when() <= w);
101 } else if (when() == w ) {
103 } else if (when() > w )
112 Moment dt = (w - when());
113 Commands_at * c = new Commands_at(dt, *this);
122 Input_commands::find_moment(Moment m)
127 Input_commands::Input_commands(Input_commands const&src)
130 IPointerList<Commands_at*> &me(*this);
131 const IPointerList<Commands_at*> &that(src);
136 Input_commands::Input_commands()
139 Commands_at * p = new Commands_at(0,0);
145 Input_commands::do_skip(int bars, Moment wholes)
148 Moment b = ptr->barleft();
149 ptr.find_moment(ptr->when() + b);
153 ptr.find_moment(ptr->when() + wholes);
159 Input_commands::add(Input_command c, Assoc<String,Moment> &marks_assoc_r)
162 if (s == "CADENZA") {
163 ptr->tdescription_.set_cadenza((int)c.args[1]);
164 } if (s == "PARTIAL") {
165 ptr->setpartial(c.args[1]);
166 } else if (s == "GROUPING") {
167 Input_command *ic = new Input_command(c);
168 ic->args.insert(ptr->tdescription_.one_beat, 1);
170 } else if (s == "METER") {
171 int beats_per_meas = c.args[1];
172 int one_beat = c.args[2];
173 Input_command *ch = get_meterchange_command(beats_per_meas, one_beat);
175 } else if (s == "SKIP") {
176 int bars = c.args[1] ;
177 Moment wholes= c.args[2];
178 do_skip(bars, wholes);
179 } else if (s == "RESET") {
181 } else if (s=="GOTO") {
184 if (!marks_assoc_r.elt_query(m))
185 error("Unknown marker: `" +m + "\'");
187 ptr.find_moment(marks_assoc_r[m]);
189 Input_command *ic = new Input_command(c);
196 Input_commands::parse(Staff * staff_l) const
199 for (iter_top(*this,i); i.ok(); i++) {
201 Staff_column* col_l = staff_l->get_col(i->when(), false);
202 if (!col_l->staff_commands_p_)
203 col_l->staff_commands_p_ = new Staff_commands_at(i->tdescription_);
205 Staff_commands_at * com_l = col_l->staff_commands_p_;
207 if (!i->when()) { /* all pieces should start with a breakable. */
208 com_l->set_breakable();
217 Input_commands::print() const
220 for (iter_top(*this,cc); cc.ok() ; cc++) {
228 Input_cursor::when()const
230 return (*this)->when();
232 Input_cursor::Input_cursor(PCursor<Commands_at *>c)
233 : PCursor<Commands_at*>(c)