1 #include "GroupInterface.h"
2 #include "FunctionalInterface.h"
3 #include "GroupBlock.h"
5 GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _level) throw(Exception) : ConnectedInterface(_owner,_name,"expression","",_direction,AbstractInterface::Data,_level) {
6 if (! _owner->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));
8 /* If the owner group is the top group, then all its interfaces are at top level => force them to be top.
9 If not, force them to be basic
11 if (((GroupBlock*)_owner)->isTop()) {
12 level = AbstractInterface::Top;
15 level = AbstractInterface::Basic;
20 bool GroupInterface::isGroupInterface() {
24 AbstractInterface *GroupInterface::clone() {
25 GroupInterface *inter = new GroupInterface(owner,name,direction,level);
26 inter->setWidth(width);
27 inter->setDirection(direction);
28 inter->setPurpose(purpose);
29 inter->setLevel(level);
30 inter->connectFrom(NULL);
36 bool GroupInterface::canConnectTo(AbstractInterface *iface) {
39 necessary conditions :
40 - iface type must be functional or group interface
41 - iface->connectedFrom must be NULL
44 1 - this is owned by the parent group of the block (group or func) that owns iface
45 1.1 - this is input and iface is input
47 2 - this is owned by a group that has the same parent as the block (group or func) that owns iface
48 2.1 - this is an output, iface is an input of the group
50 3 - this is owned by a group and iface by its parent group
51 2.1 - this is an output, iface is an output of the group
56 if (iface->isReferenceInterface()) return false;
57 if (iface->getConnectedFrom() != NULL) return false;
59 if (this->getOwner() == iface->getOwner()->getParent()) {
60 if ((direction == Input) && (iface->getDirection() == Input)) return true;
61 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
64 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
65 if ((direction == Output) && (iface->getDirection() == Input)) return true;
66 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
68 else if (this->getOwner()->getParent() == iface->getOwner()) {
69 if ((direction == Output) && (iface->getDirection() == Output)) return true;
70 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
76 bool GroupInterface::canConnectFrom(AbstractInterface *iface) {
79 necessary conditions :
80 - iface type must be functional or group interface
81 - this->connectedFrom must be NULL
84 1 - this is owned by the parent group of the block (group or func) that owns iface
85 1.1 - this is output and iface is output
87 2 - this is owned by a group that has the same parent as the block (group or func) that owns iface
88 2.1 - this is an input, iface is an output of the group
90 3 - this is owned by a group and iface by its parent group
91 2.1 - this is an input, iface is an input of the group
94 if (iface->isReferenceInterface()) return false;
95 if (getConnectedFrom() != NULL) return false;
97 if (this->getOwner() == iface->getOwner()->getParent()) {
98 if ((direction == Output) && (iface->getDirection() == Output)) return true;
99 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
102 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
103 if ((direction == Input) && (iface->getDirection() == Output)) return true;
104 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
106 else if (this->getOwner()->getParent() == iface->getOwner()) {
107 if ((direction == Input) && (iface->getDirection() == Input)) return true;
108 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
114 void GroupInterface::connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) {
115 cout << "group interface connection validation" << endl;