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 ConnectedInterface* connIface = AI_TO_CON(iface);
45 if (connIface->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;
65 bool GroupInterface::canConnectFrom(AbstractInterface *iface) {
68 necessary conditions :
69 - iface type must be functional or group interface
70 - this->connectedFrom must be NULL
73 1 - this is owned by the parent group of the block (group or func) that owns iface
74 1.1 - this is output and iface is output
76 2 - this is owned by a group that has the same parent as the block (group or func) that owns iface
77 2.1 - this is an input, iface is an output of the group
79 3 - this is owned by a group and iface by its parent group
80 2.1 - this is an input, iface is an input of the group
82 4 - this is owned by top group and iface is an output of a source block
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;
100 else if ((getOwner()->isTopGroupBlock()) && (iface->getOwner()->isSourceBlock())) {
101 if ((direction == Input) && (iface->getDirection() == Output)) return true;
107 void GroupInterface::connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) {
108 cout << "group interface connection validation" << endl;