1 #include "GroupInterface.h"
2 #include "FunctionalInterface.h"
3 #include "GroupBlock.h"
5 GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,"expression","",_direction,_purpose) {
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, purpose);
17 inter->setWidth(width);
18 inter->connectFrom(NULL);
24 bool GroupInterface::canConnectTo(AbstractInterface *iface) {
27 necessary conditions :
28 - iface type must be functional or group interface
29 - iface->connectedFrom must be NULL
32 1 - this is owned by the parent group of the block (group or func) that owns iface
33 1.1 - this is input and iface is input
35 2 - this is owned by a group that has the same parent as the block (group or func) that owns iface
36 2.1 - this is an output, iface is an input of the group
38 3 - this is owned by a group and iface by its parent group
39 2.1 - this is an output, iface is an output of the group
44 if (iface->isReferenceInterface()) return false;
45 if (iface->getConnectedFrom() != NULL) return false;
47 if (this->getOwner() == iface->getOwner()->getParent()) {
48 if ((direction == Input) && (iface->getDirection() == Input)) return true;
49 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
52 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
53 if ((direction == Output) && (iface->getDirection() == Input)) return true;
54 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
56 else if (this->getOwner()->getParent() == iface->getOwner()) {
57 if ((direction == Output) && (iface->getDirection() == Output)) return true;
58 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
64 bool GroupInterface::canConnectFrom(AbstractInterface *iface) {
67 necessary conditions :
68 - iface type must be functional or group interface
69 - this->connectedFrom must be NULL
72 1 - this is owned by the parent group of the block (group or func) that owns iface
73 1.1 - this is output and iface is output
75 2 - this is owned by a group that has the same parent as the block (group or func) that owns iface
76 2.1 - this is an input, iface is an output of the group
78 3 - this is owned by a group and iface by its parent group
79 2.1 - this is an input, iface is an input of the group
82 if (iface->isReferenceInterface()) return false;
83 if (getConnectedFrom() != NULL) return false;
85 if (this->getOwner() == iface->getOwner()->getParent()) {
86 if ((direction == Output) && (iface->getDirection() == Output)) return true;
87 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
90 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
91 if ((direction == Input) && (iface->getDirection() == Output)) return true;
92 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
94 else if (this->getOwner()->getParent() == iface->getOwner()) {
95 if ((direction == Input) && (iface->getDirection() == Input)) return true;
96 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
102 void GroupInterface::connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) {
103 cout << "group interface connection validation" << endl;