1 #include "ArithmeticEvaluator.h"
\r
2 #include "ConnectedInterface.h"
\r
3 #include "FunctionalBlock.h"
\r
4 #include "GroupBlock.h"
\r
7 ConnectedInterface::ConnectedInterface(AbstractBlock* _owner) : AbstractInterface(_owner) {
\r
8 connectedFrom = NULL;
\r
9 outputPattern = NULL;
\r
13 ConnectedInterface::ConnectedInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width) : AbstractInterface(_owner, _name, _direction, _purpose, _type, _width) {
\r
14 connectedFrom = NULL;
\r
15 outputPattern = NULL;
\r
18 ConnectedInterface::~ConnectedInterface() {
\r
19 if (outputPattern != NULL) delete outputPattern;
\r
22 /* NB/ became useless since disconnectTo does the job
\r
24 void ConnectedInterface::removeConnectedTo(ConnectedInterface *iface) {
\r
25 connectedTo.removeAll(iface);
\r
29 void ConnectedInterface::clearConnections() {
\r
30 connectedFrom = NULL;
\r
31 connectedTo.clear();
\r
34 void ConnectedInterface::clearConnectedTo() {
\r
35 connectedTo.clear();
\r
38 void ConnectedInterface::setOutputPattern(QList<char>* pattern) {
\r
39 if (outputPattern != NULL) delete outputPattern;
\r
40 outputPattern = pattern;
\r
42 void ConnectedInterface::connectTo(ConnectedInterface *iface) {
\r
44 connectedTo.append(iface);
\r
45 iface->connectedFrom = this;
\r
46 ConnectedInterface* asso1 = (ConnectedInterface*)associatedIface;
\r
47 ConnectedInterface* asso2 = (ConnectedInterface*)(iface->associatedIface);
\r
48 if ((asso1 != NULL) && (asso2 != NULL)) {
\r
49 asso1->connectedTo.append(asso2);
\r
50 asso2->connectedFrom = asso1;
\r
54 void ConnectedInterface::disconnectTo(ConnectedInterface *iface) {
\r
56 connectedTo.removeAll(iface);
\r
57 iface->connectedFrom = NULL;
\r
58 ConnectedInterface* asso1 = (ConnectedInterface*)associatedIface;
\r
59 ConnectedInterface* asso2 = (ConnectedInterface*)(iface->associatedIface);
\r
60 if ((asso1 != NULL) && (asso2 != NULL)) {
\r
61 asso1->connectedTo.removeAll(asso2);
\r
62 asso2->connectedFrom = NULL;
\r
68 bool ConnectedInterface::connectFrom(ConnectedInterface *iface) {
\r
69 if (canConnectFrom(iface)) {
\r
70 connectedFrom = iface;
\r
77 /* getConnectionToParentGroup() :
\r
78 if an interface among connectedTo is an interface of the parent group
\r
81 ConnectedInterface* ConnectedInterface::getConnectionToParentGroup() {
\r
82 foreach(ConnectedInterface *iface, connectedTo) {
\r
83 if (owner->getParent() == iface->owner) {
\r
90 /* getConnectionFromParentGroup() :
\r
91 if connectedFrom is an interface of the parent group
\r
94 ConnectedInterface *ConnectedInterface::getConnectionFromParentGroup() {
\r
95 if ((connectedFrom != NULL) && (owner->getParent() == connectedFrom->owner)) {
\r
96 return connectedFrom;
\r