X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/abbc64cf04a35ab3549d5c516f44c7c5921baa63..84eeae848c9d322ea4c935b8ec7338f69becbc10:/BlockImplementation.cpp diff --git a/BlockImplementation.cpp b/BlockImplementation.cpp index 571b72b..b751021 100644 --- a/BlockImplementation.cpp +++ b/BlockImplementation.cpp @@ -5,10 +5,13 @@ #include "ReferenceInterface.h" #include "FunctionalInterface.h" #include "BlockParameter.h" +#include BlockImplementation::BlockImplementation(const QString& _xmlFile) { - xmlFile = _xmlFile; + xmlFile = _xmlFile; + productionCounter = ""; + delta = ""; evaluator = new ArithmeticEvaluator; evaluator->setVariableMarkers("@$"); @@ -16,10 +19,78 @@ BlockImplementation::BlockImplementation(const QString& _xmlFile) { BlockImplementation::BlockImplementation(const QString& _xmlFile, const QString &_referenceXml, const QString &_referenceMd5) { xmlFile = _xmlFile; + productionCounter = ""; + delta = ""; referenceXml = _referenceXml; referenceMd5 = _referenceMd5; } +void BlockImplementation::loadPatterns(QDomElement& root) throw(Exception) { + + QDomNodeList patternNode = root.elementsByTagName("patterns"); + + if (patternNode.isEmpty()) { + cout << "impl has no patterns" << endl; + return; + } + + QDomElement patternElt = patternNode.at(0).toElement(); + + QDomElement eltDelta = patternElt.firstChildElement("delta"); + delta = eltDelta.attribute("value","none"); + + QDomElement eltCons = eltDelta.nextSiblingElement("consumption"); + + QDomNodeList listNodeInput = eltCons.elementsByTagName("input"); + for(int i=0; i iterP(productionPattern); + while (iterP.hasNext()) { + iterP.next(); + cout << qPrintable(iterP.key()) << " -> " << qPrintable(iterP.value()) << endl; + } + cout << "impls patterns read correctly" << endl; +} + +bool BlockImplementation::checkPatterns() { + if (reference == NULL) return false; + + AbstractInterface* iface; + QHashIterator iterI(consumptionPattern); + while (iterI.hasNext()) { + iterI.next(); + iface = reference->getIfaceFromName(iterI.key()); + if (iface == NULL) return false; + } + QHashIterator iterO(productionPattern); + while (iterO.hasNext()) { + iterO.next(); + iface = reference->getIfaceFromName(iterO.key()); + if (iface == NULL) return false; + } + return true; +} + void BlockImplementation::generateVHDL(FunctionalBlock* _block, const QString &path) throw(Exception) { block = _block; @@ -503,7 +574,12 @@ QDataStream& operator<<(QDataStream &out, const BlockImplementation &impl) { toWrite << impl.xmlFile; toWrite << impl.referenceXml; toWrite << impl.referenceMd5; - + // saving patterns + toWrite << impl.delta; + toWrite << impl.consumptionPattern; + toWrite << impl.productionPattern; + toWrite << impl.productionCounter; + out << blockData; return out; @@ -520,6 +596,11 @@ QDataStream& operator>>(QDataStream &in, BlockImplementation &impl) { in >> impl.xmlFile; in >> impl.referenceXml; in >> impl.referenceMd5; + // loading patterns + in >> impl.delta; + in >> impl.consumptionPattern; + in >> impl.productionPattern; + in >> impl.productionCounter; return in; }