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
10 inputModifier = NULL;
\r
14 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
15 connectedFrom = NULL;
\r
16 outputPattern = NULL;
\r
17 inputModifier = NULL;
\r
20 ConnectedInterface::~ConnectedInterface() {
\r
21 if (outputPattern != NULL) delete outputPattern;
\r
24 /* NB/ became useless since disconnectTo does the job
\r
26 void ConnectedInterface::removeConnectedTo(ConnectedInterface *iface) {
\r
27 connectedTo.removeAll(iface);
\r
31 void ConnectedInterface::clearConnections() {
\r
32 connectedFrom = NULL;
\r
33 connectedTo.clear();
\r
36 void ConnectedInterface::clearConnectedTo() {
\r
37 connectedTo.clear();
\r
40 void ConnectedInterface::setOutputPattern(QList<char>* pattern) {
\r
41 if (outputPattern != NULL) delete outputPattern;
\r
42 outputPattern = pattern;
\r
45 void ConnectedInterface::connectTo(ConnectedInterface *iface) {
\r
47 connectedTo.append(iface);
\r
48 iface->connectedFrom = this;
\r
49 ConnectedInterface* asso1 = (ConnectedInterface*)associatedIface;
\r
50 ConnectedInterface* asso2 = (ConnectedInterface*)(iface->associatedIface);
\r
51 if ((asso1 != NULL) && (asso2 != NULL)) {
\r
52 asso1->connectedTo.append(asso2);
\r
53 asso2->connectedFrom = asso1;
\r
57 void ConnectedInterface::disconnectTo(ConnectedInterface *iface) {
\r
59 connectedTo.removeAll(iface);
\r
60 iface->connectedFrom = NULL;
\r
61 ConnectedInterface* asso1 = (ConnectedInterface*)associatedIface;
\r
62 ConnectedInterface* asso2 = (ConnectedInterface*)(iface->associatedIface);
\r
63 if ((asso1 != NULL) && (asso2 != NULL)) {
\r
64 asso1->connectedTo.removeAll(asso2);
\r
65 asso2->connectedFrom = NULL;
\r
71 bool ConnectedInterface::connectFrom(ConnectedInterface *iface) {
\r
72 if (canConnectFrom(iface)) {
\r
73 connectedFrom = iface;
\r
80 /* getConnectionToParentGroup() :
\r
81 if an interface among connectedTo is an interface of the parent group
\r
84 ConnectedInterface* ConnectedInterface::getConnectionToParentGroup() {
\r
85 foreach(ConnectedInterface *iface, connectedTo) {
\r
86 if (owner->getParent() == iface->owner) {
\r
93 /* getConnectionFromParentGroup() :
\r
94 if connectedFrom is an interface of the parent group
\r
97 ConnectedInterface *ConnectedInterface::getConnectionFromParentGroup() {
\r
98 if ((connectedFrom != NULL) && (owner->getParent() == connectedFrom->owner)) {
\r
99 return connectedFrom;
\r
104 void ConnectedInterface::clearInputModifier() {
\r
105 if (inputModifier != NULL) delete inputModifier;
\r
106 inputModifier = NULL;
\r