]> AND Private Git Repository - blast.git/blob - ConnectedInterface.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
added clk/rst link when creating a block
[blast.git] / ConnectedInterface.cpp
1 #include "ArithmeticEvaluator.h"\r
2 #include "ConnectedInterface.h"\r
3 #include "FunctionalBlock.h"\r
4 #include "GroupBlock.h"\r
5 \r
6 \r
7 ConnectedInterface::ConnectedInterface(AbstractBlock* _owner) : AbstractInterface(_owner) {\r
8   connectedFrom = NULL;\r
9   outputPattern = NULL;\r
10   inputModifier = NULL;\r
11       \r
12 }\r
13 \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
18 }\r
19 \r
20 ConnectedInterface::~ConnectedInterface() {  \r
21   if (outputPattern != NULL) delete outputPattern;\r
22 }\r
23 \r
24 /* NB/ became useless since disconnectTo does the job\r
25  \r
26 void ConnectedInterface::removeConnectedTo(ConnectedInterface *iface) {\r
27   connectedTo.removeAll(iface);\r
28 }\r
29 */\r
30 \r
31 void ConnectedInterface::clearConnections() {\r
32   connectedFrom = NULL;\r
33   connectedTo.clear();\r
34 }\r
35 \r
36 void ConnectedInterface::clearConnectedTo() {\r
37   connectedTo.clear();\r
38 }\r
39 \r
40 void ConnectedInterface::setOutputPattern(QList<char>* pattern) {\r
41   if (outputPattern != NULL) delete outputPattern;\r
42   outputPattern = pattern; \r
43 }\r
44 \r
45 void ConnectedInterface::connectTo(ConnectedInterface *iface) {\r
46   \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
54   }\r
55 }\r
56 \r
57 void ConnectedInterface::disconnectTo(ConnectedInterface *iface) {\r
58   \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
66   }\r
67 }\r
68 \r
69 \r
70 /*\r
71 bool ConnectedInterface::connectFrom(ConnectedInterface *iface) {\r
72   if (canConnectFrom(iface)) {\r
73     connectedFrom = iface;\r
74     return true;\r
75   }\r
76   return false;\r
77 }\r
78 */\r
79 \r
80 /* getConnectionToParentGroup() :\r
81    if an interface among connectedTo is an interface of the parent group\r
82    returns it.\r
83 */\r
84 ConnectedInterface* ConnectedInterface::getConnectionToParentGroup() {\r
85   foreach(ConnectedInterface *iface, connectedTo) {\r
86     if (owner->getParent() == iface->owner) {\r
87       return iface;\r
88     }\r
89   }\r
90   return NULL;\r
91 }\r
92 \r
93 /* getConnectionFromParentGroup() :\r
94    if connectedFrom is an interface of the parent group\r
95    returns it.\r
96 */\r
97 ConnectedInterface *ConnectedInterface::getConnectionFromParentGroup() {\r
98   if ((connectedFrom != NULL) && (owner->getParent() == connectedFrom->owner)) {\r
99     return connectedFrom;\r
100   }\r
101   return NULL;\r
102 }\r
103 \r
104 void ConnectedInterface::clearInputModifier() {\r
105   if (inputModifier != NULL) delete inputModifier;\r
106   inputModifier = NULL;\r
107 }\r