+\r
+ // clear input pattern\r
+ clearInputPattern();\r
+ }\r
+}\r
+*/\r
+bool FunctionalBlock::samePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol) {\r
+ \r
+ if (patternSrc.size() != patternDest.size()) return false;\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterSrc(patternSrc);\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterDest(patternDest);\r
+ while (iterSrc.hasNext()) {\r
+ iterSrc.next();\r
+ iterDest.next(); \r
+ QList<char>* srcPat = iterSrc.value();\r
+ QList<char>* destPat = iterDest.value();\r
+ if (srcCol >= srcPat->size()) return false;\r
+ if (destCol >= destPat->size()) return false;\r
+ if (srcPat->at(srcCol) != destPat->at(destCol)) return false; \r
+ }\r
+ return true;\r
+}\r
+\r
+bool FunctionalBlock::samePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, const QList<int> &srcCols, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol) {\r
+ if (patternSrc.size() != srcCols.size()) return false;\r
+ if (patternSrc.size() != patternDest.size()) return false;\r
+\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterSrc(patternSrc);\r
+ QListIterator<int> iterSrcCol(srcCols);\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterDest(patternDest);\r
+ while (iterSrc.hasNext()) {\r
+ iterSrc.next();\r
+ int srcCol = iterSrcCol.next();\r
+ iterDest.next();\r
+ QList<char>* srcPat = iterSrc.value();\r
+ QList<char>* destPat = iterDest.value();\r
+ if (srcCol >= srcPat->size()) return false;\r
+ if (destCol >= destPat->size()) return false;\r
+ if (srcPat->at(srcCol) != destPat->at(destCol)) return false;\r
+ }\r
+ return true;\r
+}\r
+\r
+bool FunctionalBlock::canCombinePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int destCol) {\r
+ if (patternSrc.size() != patternDest.size()) return false;\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterSrc(patternSrc);\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterDest(patternDest);\r
+ while (iterSrc.hasNext()) {\r
+ iterSrc.next();\r
+ iterDest.next(); \r
+ QList<char>* srcPat = iterSrc.value();\r
+ QList<char>* destPat = iterDest.value();\r
+ if (srcCol >= srcPat->size()) return false;\r
+ if (destCol >= destPat->size()) return false;\r
+ if ((srcPat->at(srcCol) == -1) && (destPat->at(destCol) == 1)) return false;\r
+ if ((srcPat->at(srcCol) == 1) && (destPat->at(destCol) == -1)) return false;\r
+ }\r
+ return true;\r
+}\r
+\r
+void FunctionalBlock::combinePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int destCol) {\r
+ if (patternSrc.size() != patternDest.size()) return;\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterSrc(patternSrc);\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterDest(patternDest);\r
+ while (iterSrc.hasNext()) {\r
+ iterSrc.next();\r
+ iterDest.next(); \r
+ QList<char>* srcPat = iterSrc.value();\r
+ QList<char>* destPat = iterDest.value();\r
+ if (srcCol >= srcPat->size()) return;\r
+ if (destCol >= destPat->size()) return;\r
+ if ((srcPat->at(srcCol) == -1) && (destPat->at(destCol) == 1)) return;\r
+ if ((srcPat->at(srcCol) == 1) && (destPat->at(destCol) == -1)) return; \r
+ destPat->replace(destCol,destPat->at(destCol) | srcPat->at(srcCol));\r
+ } \r
+}\r
+\r
+void FunctionalBlock::appendToPattern(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int nbCols) {\r
+ if (patternSrc.size() != patternDest.size()) return;\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterSrc(patternSrc);\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterDest(patternDest);\r
+ while (iterSrc.hasNext()) {\r
+ iterSrc.next();\r
+ iterDest.next(); \r
+ QList<char>* srcPat = iterSrc.value();\r
+ QList<char>* destPat = iterDest.value(); \r
+ int i=0;\r
+ while ((srcCol+i < srcPat->size()) && (i<nbCols)) {\r
+ destPat->append(srcPat->at(srcCol+i));\r
+ i++;\r
+ }\r
+ } \r
+}\r
+\r
+void FunctionalBlock::removeDataGroup(QMap<AbstractInterface *, QList<char> *> &pattern, int offset) {\r
+ QMapIterator<AbstractInterface*, QList<char>* > iterSrc(pattern); \r
+ while (iterSrc.hasNext()) {\r
+ iterSrc.next(); \r
+ QList<char>* srcPat = iterSrc.value();\r
+ if (offset < srcPat->size()) {\r
+ srcPat->removeAt(offset);\r