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 {";
14 for (PCursor<Input_command *> cc(*this); cc.ok(); cc++)
24 Commands_at::Commands_at(Real dt, Commands_at* prev)
25 : moment_(dt, (prev)? &prev->moment_ : 0)
27 if (prev&& !moment_.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 moment_.set_meter(l,o);
42 bottom().add(get_grouping_command( moment_.one_beat,
43 get_default_grouping(l)));
48 Commands_at::Commands_at(Commands_at const&src) :
51 IPointerList<Input_command*> &me(*this);
52 const IPointerList<Input_command*> &that(src);
58 Commands_at::setpartial(Real p)
60 moment_.setpartial(p);
64 Commands_at::barleft()
66 return moment_.barleft();
70 Commands_at::parse(Staff_commands_at*s)
73 for (PCursor<Input_command *> cc(*this); cc.ok(); cc++) {
74 if (cc->args.sz() && cc->args[0] !="") {
84 Input_cursor::find_moment(Real w)
89 *this = list().bottom();
90 Real dt = (w - when()) <? ptr()->barleft();
92 Commands_at * c = new Commands_at(dt, *this);
93 assert(c->when() <= w);
95 } else if (when() == w ) {
97 } else if (when() > w )
106 Real dt = (w - when());
107 Commands_at * c = new Commands_at(dt, *this);
115 Input_commands::Input_commands(Input_commands const&src)
118 IPointerList<Commands_at*> &me(*this);
119 const IPointerList<Commands_at*> &that(src);
124 Input_commands::Input_commands()
127 Commands_at * p = new Commands_at(0,0);
133 Input_commands::do_skip(int bars, Real wholes)
136 Real b = ptr->barleft();
137 ptr.find_moment(ptr->when() + b);
141 ptr.find_moment(ptr->when() + wholes);
147 Input_commands::add(Input_command c)
149 if (c.args[0] == "PARTIAL") {
150 ptr->setpartial(c.args[1]);
151 } else if (c.args[0] == "GROUPING") {
152 Input_command *ic = new Input_command(c);
153 ic->args.insert(ptr->moment_.one_beat, 1);
155 } else if (c.args[0] == "METER") {
156 int beats_per_meas = c.args[1];
157 int one_beat = c.args[2];
158 Input_command *ch = get_meterchange_command(beats_per_meas, one_beat);
160 } else if (c.args[0] == "SKIP") {
161 int bars = c.args[1] ;
162 Real wholes= c.args[2];
163 do_skip(bars, wholes);
164 } else if (c.args[0] == "RESET") {
167 Input_command *ic = new Input_command(c);
174 Input_commands::parse() const
177 Staff_commands*nc = new Staff_commands;
179 for (PCursor<Commands_at*> i(*this); i.ok(); i++) {
181 Staff_commands_at* s= nc->find(i->when());
183 s = new Staff_commands_at(i->moment_);
186 if (!i->when()) { /* all pieces should start with a breakable. */
201 Input_commands::print() const
204 for (PCursor<Commands_at*> cc(*this); cc.ok() ; cc++) {
212 Input_cursor::when()const
214 return (*this)->when();
216 Input_cursor::Input_cursor(PCursor<Commands_at *>c)
217 : PCursor<Commands_at*>(c)