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,"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);
22 bool GroupInterface::canConnectTo(AbstractInterface *iface) {
25 necessary conditions :
26 - iface type must be functional or group interface
27 - iface->connectedFrom must be NULL
30 1 - this is owned by the parent group of the block (group or func) that owns iface
31 1.1 - this is input and iface is input
33 2 - this is owned by a group that has the same parent as the block (group or func) that owns iface
34 2.1 - this is an output, iface is an input of the group
36 3 - this is owned by a group and iface by its parent group
37 2.1 - this is an output, iface is an output of the group
43 if (iface->isReferenceInterface()) return false;
44 if (iface->getConnectedFrom() != NULL) return false;
46 if (this->getOwner() == iface->getOwner()->getParent()) {
47 if ((direction == Input) && (iface->getDirection() == Input)) return true;
48 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
51 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
52 if ((direction == Output) && (iface->getDirection() == Input)) return true;
53 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
55 else if (this->getOwner()->getParent() == iface->getOwner()) {
56 if ((direction == Output) && (iface->getDirection() == Output)) return true;
57 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
81 4 - this is owned by top group and iface is an output of a source block
83 if (iface->isReferenceInterface()) return false;
84 if (getConnectedFrom() != NULL) return false;
86 if (this->getOwner() == iface->getOwner()->getParent()) {
87 if ((direction == Output) && (iface->getDirection() == Output)) return true;
88 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
91 else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
92 if ((direction == Input) && (iface->getDirection() == Output)) return true;
93 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
95 else if (this->getOwner()->getParent() == iface->getOwner()) {
96 if ((direction == Input) && (iface->getDirection() == Input)) return true;
97 if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
99 else if ((getOwner()->isTopGroupBlock()) && (iface->getOwner()->isSourceBlock())) {
100 if ((direction == Input) && (iface->getDirection() == Output)) return true;
106 void GroupInterface::connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) {
107 cout << "group interface connection validation" << endl;