1 #include "inputcommands.hh"
2 #include "inputcommand.hh"
4 #include "staffcommands.hh"
5 #include "getcommand.hh"
9 Commands_at::print() const
12 mtor << "Commands_at {";
13 tdescription_.print();
14 for (PCursor<Input_command *> cc(*this); cc.ok(); cc++)
22 return tdescription_.when;
24 Commands_at::Commands_at(Moment dt, Commands_at* prev)
25 : tdescription_(dt, (prev)? &prev->tdescription_ : 0)
27 if (prev&& !tdescription_.whole_in_measure) {
28 bottom().add(get_bar_command());
33 Commands_at::add(Input_command *i)
37 // should check for other meterchanges here.
38 if (i->args[0] == "METER") {
41 tdescription_.set_meter(l,o);
42 bottom().add(get_grouping_command( get_default_grouping(l)));
47 Commands_at::Commands_at(Commands_at const&src) :
48 tdescription_(src.tdescription_)
50 IPointerList<Input_command*> &me(*this);
51 const IPointerList<Input_command*> &that(src);
57 Commands_at::setpartial(Moment p)
59 tdescription_.setpartial(p);
63 Commands_at::barleft()
65 return tdescription_.barleft();
69 Commands_at::parse(Staff_commands_at*s)
71 s->tdescription_ = tdescription_;
72 for (PCursor<Input_command *> cc(*this); cc.ok(); cc++) {
73 if (cc->args.sz() && cc->args[0] !="") {
83 Input_cursor::find_moment(Moment w)
88 *this = list().bottom();
89 Moment dt = (w - when()) <? ptr()->barleft();
91 Commands_at * c = new Commands_at(dt, *this);
92 assert(c->when() <= w);
94 } else if (when() == w ) {
96 } else if (when() > w )
105 Moment dt = (w - when());
106 Commands_at * c = new Commands_at(dt, *this);
114 Input_commands::Input_commands(Input_commands const&src)
117 IPointerList<Commands_at*> &me(*this);
118 const IPointerList<Commands_at*> &that(src);
123 Input_commands::Input_commands()
126 Commands_at * p = new Commands_at(0,0);
132 Input_commands::do_skip(int bars, Moment wholes)
135 Moment b = ptr->barleft();
136 ptr.find_moment(ptr->when() + b);
140 ptr.find_moment(ptr->when() + wholes);
146 Input_commands::add(Input_command c)
148 if (c.args[0] == "PARTIAL") {
149 ptr->setpartial(c.args[1]);
150 } else if (c.args[0] == "GROUPING") {
151 Input_command *ic = new Input_command(c);
152 ic->args.insert(ptr->tdescription_.one_beat, 1);
154 } else if (c.args[0] == "METER") {
155 int beats_per_meas = c.args[1];
156 int one_beat = c.args[2];
157 Input_command *ch = get_meterchange_command(beats_per_meas, one_beat);
159 } else if (c.args[0] == "SKIP") {
160 int bars = c.args[1] ;
161 Moment wholes= c.args[2];
162 do_skip(bars, wholes);
163 } else if (c.args[0] == "RESET") {
166 Input_command *ic = new Input_command(c);
173 Input_commands::parse() const
176 Staff_commands*nc = new Staff_commands;
178 for (PCursor<Commands_at*> i(*this); i.ok(); i++) {
180 Staff_commands_at* s= nc->find(i->when());
182 s = new Staff_commands_at(i->tdescription_);
185 if (!i->when()) { /* all pieces should start with a breakable. */
200 Input_commands::print() const
203 for (PCursor<Commands_at*> cc(*this); cc.ok() ; cc++) {
211 Input_cursor::when()const
213 return (*this)->when();
215 Input_cursor::Input_cursor(PCursor<Commands_at *>c)
216 : PCursor<Commands_at*>(c)