X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/3bbc311e444c1ef9ac66dd6861fb0acb13ddb72a..2bdaa0aa3fab52f0808f60d9bbdabcd56d0efae9:/GroupInterface.cpp diff --git a/GroupInterface.cpp b/GroupInterface.cpp index 934ad08..5f292b6 100644 --- a/GroupInterface.cpp +++ b/GroupInterface.cpp @@ -2,10 +2,14 @@ #include "FunctionalInterface.h" #include "GroupBlock.h" -GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,"inherited","",_direction,_purpose) { +GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,_direction,_purpose,"inherited","") { if (! _owner->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE)); connectedFrom = NULL; + // force clock and reset to boolean width type instead of inherited + if ((purpose == Clock) || (purpose == Reset)) { + type = Boolean; + } } bool GroupInterface::isGroupInterface() { @@ -18,6 +22,27 @@ AbstractInterface *GroupInterface::clone() { return inter; } +int GroupInterface::getWidth() { + + bool ok; + int w = -1; + + QString expr = width; + + if (type == Boolean) { + return 1; + } + else if (type == Inherited) { + // must search from which iface it is connected. + ConnectedInterface* fromIface = connectedFrom; + while ((fromIface != NULL) && (fromIface->getType() == Inherited)) { + fromIface = fromIface->getConnectedFrom(); + } + if (fromIface == NULL) return -1; + w = fromIface->getWidth(); + } + return w; +} bool GroupInterface::canConnectTo(AbstractInterface *iface) { @@ -41,20 +66,21 @@ bool GroupInterface::canConnectTo(AbstractInterface *iface) { */ if (iface->isReferenceInterface()) return false; - if (iface->getConnectedFrom() != NULL) return false; + ConnectedInterface* connIface = AI_TO_CON(iface); + if (connIface->getConnectedFrom() != NULL) return false; if (this->getOwner() == iface->getOwner()->getParent()) { - if ((direction == Input) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Output) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (this->getOwner()->getParent() == iface->getOwner()) { - if ((direction == Output) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } @@ -84,20 +110,20 @@ bool GroupInterface::canConnectFrom(AbstractInterface *iface) { if (getConnectedFrom() != NULL) return false; if (this->getOwner() == iface->getOwner()->getParent()) { - if ((direction == Output) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Input) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (this->getOwner()->getParent() == iface->getOwner()) { - if ((direction == Input) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if ((getOwner()->isTopGroupBlock()) && (iface->getOwner()->isSourceBlock())) { - if ((direction == Input) && (iface->getDirection() == Output)) return true; + if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; } return false;