From: fred Date: Sat, 21 Dec 1996 11:30:09 +0000 (+0000) Subject: lilypond-0.0.19 X-Git-Tag: release/1.5.59~6525 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6d4ca4475a19404bbdce92ab17eeda3c6a9faa60;p=lilypond.git lilypond-0.0.19 --- diff --git a/src/staffcommands.cc b/src/staffcommands.cc index 2837de161c..a0bb71f84c 100644 --- a/src/staffcommands.cc +++ b/src/staffcommands.cc @@ -2,12 +2,18 @@ #include "debug.hh" #include "parseconstruct.hh" +Real +Staff_commands_at::when() +{ + return moment_.when; +} void Staff_commands_at::print() const { #ifndef NPRINT PCursor i (*this); - mtor << "Commands at: " << when<<"\n"; + mtor << "Commands at: " ; + moment_.print(); for (; i.ok(); i++) i->print(); @@ -22,9 +28,10 @@ Staff_commands_at::OK()const assert(i->priority >= (i+1)->priority); } -Staff_commands_at::Staff_commands_at(Real r) +Staff_commands_at::Staff_commands_at(Moment m) + :moment_(m) { - when = r; + } bool @@ -200,9 +207,8 @@ Staff_commands::OK() const { #ifndef NDEBUG for (PCursor i(*this); i.ok() && (i+1).ok(); i++) { - assert(i->when <= (i+1)->when); + assert(i->moment_.when <= (i+1)->moment_.when); i->OK(); - } #endif } @@ -222,41 +228,44 @@ Staff_commands::find(Real w) { PCursor i(bottom()); for (; i.ok() ; i--) { - if (i->when == w) + if (i->moment_.when == w) return i; - if (i->when < w) + if (i->moment_.when < w) + break; + } + return 0; +} + +void +Staff_commands::add(Staff_commands_at*p) +{ + PCursor i(bottom()); + for (; i.ok() ; i--) { + if (i->moment_.when < p->moment_.when) break; } - Staff_commands_at*p =new Staff_commands_at(w); if (!i.ok()) i.insert(p); else { i.add(p); i++; } - return i; -} - -void -Staff_commands::add(Command c, Real when) -{ - Staff_commands_at* p = find(when); - p->add(c); } void Staff_commands::clean(Real l) { PCursor i(bottom()); - for (; i->when > l ; i=bottom()) { + for (; i->moment_.when > l; i=bottom()) { remove(i); } - Staff_commands_at*p = find(l); + Staff_commands_at*p = find(l); + if (!p) { + p = new Staff_commands_at(Moment(l - i->when(), &i->moment_)); + add(p); + } if (!p->is_breakable()) { p->set_breakable(); -/* Command b; - b.code = INTERPRET; - b.args.add("BAR");*/ } }