1 #include "GroupInterface.h"
2 #include "FunctionalInterface.h"
3 #include "GroupBlock.h"
5 GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction) throw(Exception) : ConnectedInterface(_owner,_name,"expression","",_direction,AbstractInterface::Data) {
6 if (! _owner->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));
11 bool GroupInterface::isGroupInterface() {
15 AbstractInterface *GroupInterface::clone() {
16 GroupInterface *inter = new GroupInterface(owner,name,direction);
17 inter->setWidth(width);
18 inter->setDirection(direction);
19 inter->setPurpose(purpose);
20 inter->connectFrom(NULL);
26 bool GroupInterface::canConnectTo(AbstractInterface *iface) {
29 necessary conditions :
30 - iface type must be functional or group interface
31 - iface->connectedFrom must be NULL
34 1 - this is owned by the parent group of the block (group or func) that owns iface
35 1.1 - this is input and iface is input
37 2 - this is owned by a group that has the same parent as the block (group or func) that owns iface
38 2.1 - this is an output, iface is an input of the group
40 3 - this is owned by a group and iface by its parent group
41 2.1 - this is an output, iface is an output of the group
46 if (iface->isReferenceInterface()) return false;
47 if (iface->getConnectedFrom() != NULL) return false;
49 if (this->getOwner() == iface->getOwner()->getParent()) {
50 if ((direction == Input) && (iface->getDirection() == Input)) return true;
51 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
54 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
55 if ((direction == Output) && (iface->getDirection() == Input)) return true;
56 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
58 else if (this->getOwner()->getParent() == iface->getOwner()) {
59 if ((direction == Output) && (iface->getDirection() == Output)) return true;
60 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
66 bool GroupInterface::canConnectFrom(AbstractInterface *iface) {
69 necessary conditions :
70 - iface type must be functional or group interface
71 - this->connectedFrom must be NULL
74 1 - this is owned by the parent group of the block (group or func) that owns iface
75 1.1 - this is output and iface is output
77 2 - this is owned by a group that has the same parent as the block (group or func) that owns iface
78 2.1 - this is an input, iface is an output of the group
80 3 - this is owned by a group and iface by its parent group
81 2.1 - this is an input, iface is an input of the group
84 if (iface->isReferenceInterface()) return false;
85 if (getConnectedFrom() != NULL) return false;
87 if (this->getOwner() == iface->getOwner()->getParent()) {
88 if ((direction == Output) && (iface->getDirection() == Output)) return true;
89 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
92 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
93 if ((direction == Input) && (iface->getDirection() == Output)) return true;
94 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
96 else if (this->getOwner()->getParent() == iface->getOwner()) {
97 if ((direction == Input) && (iface->getDirection() == Input)) return true;
98 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
104 void GroupInterface::connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) {
105 cout << "group interface connection validation" << endl;