X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/624231601a0f5daea9b8809993ad3503beafce4f..7af5c69c22148510cf8f042552018c9b966860cd:/FunctionalBlock.h diff --git a/FunctionalBlock.h b/FunctionalBlock.h index c122dcf..2cf9a5a 100644 --- a/FunctionalBlock.h +++ b/FunctionalBlock.h @@ -11,6 +11,9 @@ class ReferenceBlock; class GroupBlock; #include "Exception.h" class Exception; +class BlockImplementation; +class ArithmeticEvaluator; + using namespace std; @@ -27,12 +30,18 @@ public: // getters inline ReferenceBlock* getReference() { return reference; } - + inline QList getProductionCounter() { return productionCounter; } + inline int getDelta() { return delta; } + // setters + inline void setImplementation(BlockImplementation* impl) { implementation = impl; } + inline void setProductionCounter(QList pattern) { productionCounter = pattern; } + inline void setDelta(int _delta) { delta = _delta; } + // testers bool isFunctionalBlock(); - bool isSourceBlock(); //! a source block has no parent + bool isSourceBlock(); //! a source block has no parent and has no data inputs // others @@ -41,9 +50,94 @@ public: QString getReferenceXmlFile(); QString getReferenceHashMd5(); - + + // patterns + bool createPatterns(); + bool createDelta(); + bool createConsumptionPattern(); // initialize a QList for each interface from patterns defined in implementation + bool createProductionPattern(); // initialize a QList for each interface from patterns defined in implementation + bool createProductionCounter(); // initialize a QList from counter defined in implementation + void clearConsumptionPattern(); + void clearProductionPattern(); + bool computeOutputPattern(int nbExec = -1); + private: + // patterns + double evaluateExpression(const QString& expression, bool* ok); + QList* expandPattern(const QString& patternIn, bool* ok); + void expandPatternRecur(const QString& patternIn, int* offset, bool* ok, QList *patternOut); + /*! + * \brief canCombinePatterns + * \param patternSrc the pattern that must be combined with patternDest (patternDest = patternDest OR patternSrc) + * \param srcCol the column index within patternSrc + * \param patternDest the pattern that is modified by the combination (patternDest = patternDest OR patternSrc) + * \param destCol the column index within patternDest + * \return true if the combination is possible, and false else (e.g. when X1 must be combined with 11) + * NB: if src/destCol are outside the range of the list, false is returned. + */ + bool canCombinePatterns(const QMap* >& patternSrc, int srcCol, QMap* > patternDest, int destCol); + /*! + * \brief combinePatterns + * \param patternSrc the pattern that must be combined with patternDest (patternDest = patternDest OR patternSrc) + * \param srcCol the column index within patternSrc + * \param patternDest the pattern that is modified by the combination (patternDest = patternDest OR patternSrc) + * \param destCol the column index within patternDest + * BEWARE: this method returns as soons as there is an acces problem (i.e. out of list range, impossible combine, ...) + leaving the dest pattern in an inconsistent state. Thus, it is a good idea to call canCombine before. + */ + void combinePatterns(const QMap* >& patternSrc, int srcCol, QMap* > patternDest, int destCol); + /*! + * \brief appendToPattern + * \param patternSrc the pattern that must be appended to patternDest + * \param srcCol the column index within patternSrc + * \param patternDest the pattern that is modified by the append + * \param nbCols the numer of columns to append + * BEWARE: if nbCols is not consistent with the real length of src pattern, there may be less that nbCols + * that will be appended + */ + void appendToPattern(const QMap* >& patternSrc, int srcCol, QMap* > patternDest, int nbCols); + /*! + * \brief removeDataGroup + * \param pattern the pattern for which a column is removed + * \param offset the index of the column to remove + */ + void removeDataGroup(QMap* >& pattern, int offset); + /*! + * \brief isValidGroup + * \param pattern the pattern to test + * \param offset the column to test + * isValidGroup checks if there is at least one 1 in the column offset of pattern. + */ + bool isValidDataGroup(const QMap* >& pattern, int offset); + /*! + * \brief isOnlyXGroup + * \param pattern the pattern to test + * \param offset the column to test + * isOnlyXGroup checks if there is only X in the column offset of pattern. + */ + bool isOnlyXDataGroup(const QMap* >& pattern, int offset); + /*! + * \brief shifRightPattern + * \param pattern the pattern to shift + * \param offset the column where to shift + * shiftRightPattern insert a null colmun in pattern, which leads to shift right the pattern at offset. + * this method is used during admittance generation + */ + void shiftRightPattern(const QMap* >& pattern, int offset); + + QMap* > consumptionPattern; + QMap admittance; // the admittance expressed as prologue-cyclic part-eppilogue + QMap* > admittanceExpanded; // the admittance expanded by taking into account nb exec. + QMap* > productionPattern; + QMap* > outputPattern; // CAUTION: the QList* must also be stored in the outputPattern attributes of AbstractInterface + QList productionCounter; //! only usefull for control output interfaces + + int delta; + + ArithmeticEvaluator* evaluator; + ReferenceBlock* reference; + BlockImplementation* implementation; };