From: fred Date: Sun, 24 Mar 2002 19:27:34 +0000 (+0000) Subject: lilypond-0.0.22 X-Git-Tag: release/1.5.59~5630 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=86d9bd8a7982cbcd3012f7a8ace57aa506f0f1e8;p=lilypond.git lilypond-0.0.22 --- diff --git a/hdr/staff.hh b/hdr/staff.hh index 5414fc3f8b..7d6be0e12f 100644 --- a/hdr/staff.hh +++ b/hdr/staff.hh @@ -9,36 +9,42 @@ struct Staff { /// synchronous horizontal stuff IPointerList voices; - /// commands in chronological order - Staff_commands *staff_commands_; - /// runtime field IPointerList cols; - /// indirections to the Score and PScore - Score *score_; - PScore *pscore_; + Score *score_l_; + PScore *pscore_l_; /****************************************************************/ void add(PointerList &s); - void process_commands(Moment l); + + /// throw away cols later the #l# + void truncate_cols(Moment l); Staff(const Staff&src); void add_voice(Voice *v); void add_staff_column(Staff_column *sp); Paperdef*paper()const; + /// interpret all requests and add items to #destination#. void process(); /** This routines calls virtual functions from Staff, to delegate the interpretation of requests to a derived class of Staff */ + + void setup_staffcols(); void OK() const; void print() const; + + /// when does the last *musical* element finish? Moment last() const; + + /// remove unused cols void clean_cols() ; + Staff_column * get_col(Moment,bool); Staff(); @@ -51,6 +57,8 @@ struct Staff { virtual void walk()=0; virtual Staff_column * create_col(Score_column * )=0; virtual ~Staff() { } +private: + void set_time_descriptions(); }; #endif diff --git a/src/staff.cc b/src/staff.cc index 825e878d8a..ef54dbe466 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -15,16 +15,18 @@ Staff::add(PointerList &l) } void -Staff::process_commands(Moment l) +Staff::truncate_cols(Moment l) { - if (staff_commands_) - staff_commands_->clean(l); + iter_bot(cols, i); + for (; i->when() > l; i=cols.bottom()) { + i.del(); + } } Paperdef* Staff::paper() const { - return score_->paper_; + return score_l_->paper_p_; } void @@ -32,7 +34,7 @@ Staff::clean_cols() { iter_top(cols,i); for(; i.ok(); ){ - if (!i->score_column->used()) + if (!i->score_column_l_->used()) i.del(); else i++; @@ -42,18 +44,18 @@ Staff::clean_cols() Staff_column * Staff::get_col(Moment w, bool mus) { - Score_column* sc = score_->find_col(w,mus); - assert(sc->when == w); + Score_column* sc = score_l_->find_col(w,mus); iter_top(cols,i); for (; i.ok(); i++) { - if (*i->score_column > *sc) // too far + + if (*i->score_column_l_ > *sc) // too far break; - if (sc == i->score_column) + if (sc == i->score_column_l_) return i; } - /* post: *sc > *->score_column || !i.ok() */ + /* post: *sc > *->score_column_l_ || !i.ok() */ Staff_column* newst = create_col(sc); if (!i.ok()) { @@ -66,8 +68,6 @@ Staff::get_col(Moment w, bool mus) return newst; } -// ; assert((i-1).ok()) - // todo! // making a fix at 2:30 am, with several beers drunk. // but it works :-) @@ -97,28 +97,24 @@ Staff::setup_staffcols() now += ve->duration; } } + set_time_descriptions(); +} - for (iter_top(*staff_commands_,cc); cc.ok(); cc++) { - Staff_column *sc=get_col(cc->tdescription_.when,false); - sc->s_commands = cc; - sc->tdescription_ = new Time_description(cc->tdescription_); - } - - iter_top(*staff_commands_,cc); +void +Staff::set_time_descriptions() +{ + Time_description t(0,0); for (iter_top(cols,i); i.ok(); i++) { - while ((cc+1).ok() && (cc+1)->when() < i->when()) - cc++; - + if (i->staff_commands_p_) + t = i->staff_commands_p_->tdescription_; + else if (i->tdescription_) + t = *i->tdescription_; if(!i->tdescription_) { - if (cc->tdescription_.when == i->when()) - i->tdescription_ = new Time_description(cc->tdescription_); - else - i->tdescription_ = new Time_description( - i->when() - cc->when() ,&cc->tdescription_); + i->tdescription_ = new Time_description(i->when() - t.when ,&t); } } -} +} void Staff::process() { @@ -133,7 +129,7 @@ Staff::OK() const #ifndef NDEBUG cols.OK(); voices.OK(); - assert(score_); + assert(score_l_); #endif } @@ -157,15 +153,12 @@ Staff::print() const for (iter_top(voices,i); i.ok(); i++) { i->print(); } - if (staff_commands_) - staff_commands_->print(); mtor <<"}\n"; #endif } Staff::Staff() { - staff_commands_ = 0; - score_ =0; - pscore_=0; + score_l_ =0; + pscore_l_ =0; }