X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/18fecf25efe710631fabecbb9f689c2997fdfe18..9bfa0c13066918f440ac2b5461fb3f8847f43fd6:/BlockImplementation.cpp?ds=sidebyside diff --git a/BlockImplementation.cpp b/BlockImplementation.cpp index 5ae6eda..23ec8bc 100644 --- a/BlockImplementation.cpp +++ b/BlockImplementation.cpp @@ -15,6 +15,8 @@ BlockImplementation::BlockImplementation(const QString& _xmlFile) { evaluator = new ArithmeticEvaluator; evaluator->setVariableMarkers("@$"); + + noPatterns = true; } BlockImplementation::BlockImplementation(const QString& _xmlFile, const QString &_referenceXml, const QString &_referenceMd5) { @@ -23,6 +25,8 @@ BlockImplementation::BlockImplementation(const QString& _xmlFile, const QString delta = ""; referenceXml = _referenceXml; referenceMd5 = _referenceMd5; + + noPatterns = true; } void BlockImplementation::loadPatterns(QDomElement& root) throw(Exception) { @@ -38,7 +42,8 @@ void BlockImplementation::loadPatterns(QDomElement& root) throw(Exception) { QDomElement eltDelta = patternElt.firstChildElement("delta"); delta = eltDelta.attribute("value","none"); - + if (delta == "none") throw(Exception(IMPLFILE_CORRUPTED)); + QDomElement eltCons = eltDelta.nextSiblingElement("consumption"); QDomNodeList listNodeInput = eltCons.elementsByTagName("input"); @@ -47,7 +52,8 @@ void BlockImplementation::loadPatterns(QDomElement& root) throw(Exception) { QDomElement elt = node.toElement(); QString nameStr = elt.attribute("name","none"); if (nameStr == "none") throw(Exception(IMPLFILE_CORRUPTED)); - QString patternStr = elt.attribute("pattern","none"); + QString patternStr = elt.attribute("pattern","none"); + if (patternStr == "none") throw(Exception(IMPLFILE_CORRUPTED)); consumptionPattern.insert(nameStr,patternStr); } @@ -61,6 +67,7 @@ void BlockImplementation::loadPatterns(QDomElement& root) throw(Exception) { QString nameStr = elt.attribute("name","none"); if (nameStr == "none") throw(Exception(IMPLFILE_CORRUPTED)); QString patternStr = elt.attribute("pattern","none"); + if (patternStr == "none") throw(Exception(IMPLFILE_CORRUPTED)); productionPattern.insert(nameStr,patternStr); } cout << "patterns summary:" << endl; @@ -70,6 +77,7 @@ void BlockImplementation::loadPatterns(QDomElement& root) throw(Exception) { cout << qPrintable(iterP.key()) << " -> " << qPrintable(iterP.value()) << endl; } cout << "impls patterns read correctly" << endl; + noPatterns = false; } bool BlockImplementation::checkPatterns() { @@ -324,6 +332,7 @@ QDataStream& operator<<(QDataStream &out, const BlockImplementation &impl) { toWrite << impl.referenceXml; toWrite << impl.referenceMd5; // saving patterns + toWrite << impl.noPatterns; toWrite << impl.delta; toWrite << impl.consumptionPattern; toWrite << impl.productionPattern; @@ -346,6 +355,7 @@ QDataStream& operator>>(QDataStream &in, BlockImplementation &impl) { in >> impl.referenceXml; in >> impl.referenceMd5; // loading patterns + in >> impl.noPatterns; in >> impl.delta; in >> impl.consumptionPattern; in >> impl.productionPattern;