/// synchronous horizontal stuff
IPointerList<Voice*> voices;
- /// commands in chronological order
- Staff_commands *staff_commands_;
-
/// runtime field
IPointerList<Staff_column*> cols;
- /// indirections to the Score and PScore
- Score *score_;
- PScore *pscore_;
+ Score *score_l_;
+ PScore *pscore_l_;
/****************************************************************/
void add(PointerList<Voice*> &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();
virtual void walk()=0;
virtual Staff_column * create_col(Score_column * )=0;
virtual ~Staff() { }
+private:
+ void set_time_descriptions();
};
#endif
}
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
{
iter_top(cols,i);
for(; i.ok(); ){
- if (!i->score_column->used())
+ if (!i->score_column_l_->used())
i.del();
else
i++;
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()) {
return newst;
}
-// ; assert((i-1).ok())
- // todo!
// making a fix at 2:30 am, with several beers drunk.
// but it works :-)
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()
{
#ifndef NDEBUG
cols.OK();
voices.OK();
- assert(score_);
+ assert(score_l_);
#endif
}
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;
}