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,AbstractInterface::Inherited,"",_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
45 if (iface->isReferenceInterface()) return false;
46 if (iface->getConnectedFrom() != NULL) return false;
48 if (this->getOwner() == iface->getOwner()->getParent()) {
49 if ((direction == Input) && (iface->getDirection() == Input)) return true;
50 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
53 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
54 if ((direction == Output) && (iface->getDirection() == Input)) return true;
55 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
57 else if (this->getOwner()->getParent() == iface->getOwner()) {
58 if ((direction == Output) && (iface->getDirection() == Output)) return true;
59 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
83 4 - this is owned by top group and iface is an output of a source block
85 if (iface->isReferenceInterface()) return false;
86 if (getConnectedFrom() != NULL) return false;
88 if (this->getOwner() == iface->getOwner()->getParent()) {
89 if ((direction == Output) && (iface->getDirection() == Output)) return true;
90 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
93 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
94 if ((direction == Input) && (iface->getDirection() == Output)) return true;
95 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
97 else if (this->getOwner()->getParent() == iface->getOwner()) {
98 if ((direction == Input) && (iface->getDirection() == Input)) return true;
99 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
101 else if ((getOwner()->isTopGroupBlock()) && (iface->getOwner()->isSourceBlock())) {
102 if ((direction == Input) && (iface->getDirection() == Output)) return true;
108 void GroupInterface::connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) {
109 cout << "group interface connection validation" << endl;