Commit ab62f5c0 authored by Florent Jacquemard's avatar Florent Jacquemard
Browse files

update converter of table to score model : new format of runs (2 subclasses inner and term.)

parent 9fef3f80
......@@ -150,6 +150,28 @@ private:
int v);
/// particular case of readTree
template<class K>
size_t readTreeInnner(ScoringEnv& env,
parsing::TableA<K>& tab,
const K& k,
const parsing::RunInner<K>* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur);
/// particular case of readTree
template<class K>
size_t readTreeTerminal(ScoringEnv& env,
parsing::TableA<K>& tab,
const K& k,
const parsing::RunTerm* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur);
/// add one tree of the current Sequence.
/// @param mult multiplicity of the top node of the tree.
/// @todo TBC parent, prev useless?
......@@ -163,27 +185,7 @@ private:
size_t b,
int voiceNb,
mtu_t dur);
template<class K>
size_t readTreeInnner(ScoringEnv& env,
parsing::TableA<K>& tab,
const K& k,
const parsing::RunInner<K>* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur);
template<class K>
size_t readTreeTerm(ScoringEnv& env,
parsing::TableA<K>& tab,
const K& k,
const parsing::RunTerm* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur);
/// add one Node in the tree of the current Sequence
/// @param b position of first point to read in input segment.
/// @param n number of points to read in input segment for the symbol.
......
......@@ -104,7 +104,8 @@ size_t TableMonoImporter::readRun(ScoringEnv& env,
// single bar mark; parse 1 measure and the rest of the run (tail recusion)
if (SymbLabel::bar(a) && (SymbLabel::arity(a) == 2))
{
const parsing::RunInner<K>* ir = dynamic_cast<parsing::RunInner<K>*>(r);
const parsing::RunInner<K>* ir =
dynamic_cast<const parsing::RunInner<K>*>(r);
assert(ir);
// first child is a measure
const parsing::Run* r0 = ir->subrun(0);
......@@ -267,56 +268,15 @@ size_t TableMonoImporter::readSequence(ScoringEnv& env,
}
/// @todo suppr. parent, prev (useless ?)
template<class K>
size_t TableMonoImporter::readTree(ScoringEnv& env,
parsing::TableA<K>& tab,
const K& k,
const parsing::Run* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur)
{
assert(r);
assert(r->fail() || r->complete());
TRACE("TableImporter[{}]: read tree: {}", b, *r);
if (r->terminal())
{
// dynamic_cast has stricter checking than regular cast
// https://stackoverflow.com/questions/28002/regular-cast-vs-static-cast-vs-dynamic-cast
const parsing::RunTerm* tr =
dynamic_cast<const parsing::RunTerm*>(r);
assert(tr);
return readTreeTerminal(env, tab, k, tr, mult, b, voiceNb, dur);
// return readTreeTerminal(env, tab, k,
// (const parsing::RunTerm*) r,
// mult, b, voiceNb, dur);
}
else
{
assert(r->inner());
const parsing::RunInner<K>* ir =
dynamic_cast<const parsing::RunInner<K>*>(r);
assert(ir);
return readTreeTerminal(env, tab, k, ir, mult, b, voiceNb, dur);
// return readTreeTerminal(env, tab, k,
// (const parsing::RunInner<K>*) r,
// mult, b, voiceNb, dur);
}
}
template<class K>
size_t TableMonoImporter::readTreeTerm(ScoringEnv& env,
parsing::TableA<K>& tab,
const K& k,
const parsing::RunTerm* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur)
size_t TableMonoImporter::readTreeTerminal(ScoringEnv& env,
parsing::TableA<K>& tab,
const K& k,
const parsing::RunTerm* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur)
{
assert(r);
size_t j = b;
......@@ -433,6 +393,48 @@ size_t TableMonoImporter::readTreeInnner(ScoringEnv& env,
}
/// @todo suppr. parent, prev (useless ?)
template<class K>
size_t TableMonoImporter::readTree(ScoringEnv& env,
parsing::TableA<K>& tab,
const K& k,
const parsing::Run* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur)
{
assert(r);
assert(r->fail() || r->complete());
TRACE("TableImporter[{}]: read tree: {}", b, *r);
if (r->terminal())
{
// dynamic_cast has stricter checking than regular cast
// https://stackoverflow.com/questions/28002/regular-cast-vs-static-cast-vs-dynamic-cast
const parsing::RunTerm* tr =
dynamic_cast<const parsing::RunTerm*>(r);
assert(tr);
return readTreeTerminal(env, tab, k, tr, mult, b, voiceNb, dur);
// return readTreeTerminal(env, tab, k,
// (const parsing::RunTerm*) r,
// mult, b, voiceNb, dur);
}
else
{
assert(r->inner());
const parsing::RunInner<K>* ir =
dynamic_cast<const parsing::RunInner<K>*>(r);
assert(ir);
size_t cu = readTreeInnner(env, tab, k, ir, mult, b, voiceNb, dur);
return cu;
// return readTreeTerminal(env, tab, k,
// (const parsing::RunInner<K>*) r,
// mult, b, voiceNb, dur);
}
}
size_t TableMonoImporter::readSymbol(ScoringEnv& env,
label_t a,
size_t arity,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment