+void BlockImplementation::loadPatterns(QDomElement& root) throw(Exception) {\r
+ \r
+ QDomNodeList patternNode = root.elementsByTagName("patterns");\r
+ \r
+ if (patternNode.isEmpty()) {\r
+ cout << "impl has no patterns" << endl;\r
+ return;\r
+ }\r
+ \r
+ QDomElement patternElt = patternNode.at(0).toElement();\r
+ \r
+ QDomElement eltDelta = patternElt.firstChildElement("delta");\r
+ delta = eltDelta.attribute("value","none");\r
+ \r
+ QDomElement eltCons = eltDelta.nextSiblingElement("consumption");\r
+ \r
+ QDomNodeList listNodeInput = eltCons.elementsByTagName("input");\r
+ for(int i=0; i<listNodeInput.size(); i++) {\r
+ QDomNode node = listNodeInput.at(i); \r
+ QDomElement elt = node.toElement(); \r
+ QString nameStr = elt.attribute("name","none");\r
+ if (nameStr == "none") throw(Exception(IMPLFILE_CORRUPTED));\r
+ QString patternStr = elt.attribute("pattern","none"); \r
+ consumptionPattern.insert(nameStr,patternStr);\r
+ }\r
+ \r
+ QDomElement eltProd = eltCons.nextSiblingElement("production");\r
+ \r
+ productionCounter = eltProd.attribute("counter","none");\r
+ QDomNodeList listNodeOutput = eltProd.elementsByTagName("output");\r
+ for(int i=0; i<listNodeOutput.size(); i++) {\r
+ QDomNode node = listNodeOutput.at(i); \r
+ QDomElement elt = node.toElement(); \r
+ QString nameStr = elt.attribute("name","none");\r
+ if (nameStr == "none") throw(Exception(IMPLFILE_CORRUPTED));\r
+ QString patternStr = elt.attribute("pattern","none"); \r
+ productionPattern.insert(nameStr,patternStr); \r
+ }\r
+ cout << "patterns summary:" << endl;\r
+ QHashIterator<QString,QString> iterP(productionPattern);\r
+ while (iterP.hasNext()) {\r
+ iterP.next();\r
+ cout << qPrintable(iterP.key()) << " -> " << qPrintable(iterP.value()) << endl;\r
+ }\r
+ cout << "impls patterns read correctly" << endl;\r
+}\r
+\r
+bool BlockImplementation::checkPatterns() {\r
+\r
+\r
+ if (reference == NULL) {\r
+ cout << "no ref. while checking patterns of implementation " << endl;\r
+ return false;\r
+ }\r
+ \r
+ AbstractInterface* iface; \r
+ QHashIterator<QString,QString> iterI(consumptionPattern);\r
+ while (iterI.hasNext()) {\r
+ iterI.next();\r
+ iface = reference->getIfaceFromName(iterI.key());\r
+ if (iface == NULL) {\r
+ cout << "cannot found an input ref. iface for impl. iface " << qPrintable(iterI.key()) << endl;\r
+ return false;\r
+ }\r
+ }\r
+ QHashIterator<QString,QString> iterO(productionPattern);\r
+ while (iterO.hasNext()) {\r
+ iterO.next();\r
+ iface = reference->getIfaceFromName(iterO.key());\r
+ if (iface == NULL) {\r
+ cout << "cannot found an output ref. iface for impl. iface " << qPrintable(iterI.key()) << endl;\r
+ return false;\r
+ }\r
+ } \r
+ return true; \r
+}\r
+\r