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

Private GIT Repository
started adding delta comput
[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 }\r
10 \r
11 ConnectedInterface::ConnectedInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose) : AbstractInterface(_owner, _name, _type, _width, _direction, _purpose) {\r
12   connectedFrom = NULL;\r
13 }\r
14 \r
15 void ConnectedInterface::removeConnectedTo(ConnectedInterface *iface) {\r
16   connectedTo.removeOne(iface);\r
17 }\r
18 \r
19 void ConnectedInterface::clearConnections() {\r
20   connectedFrom = NULL;\r
21   connectedTo.clear();\r
22 }\r
23 \r
24 void ConnectedInterface::clearConnectedTo() {\r
25   connectedTo.clear();\r
26 }\r
27 \r
28 void ConnectedInterface::connectTo(ConnectedInterface *iface) {\r
29   \r
30   connectedTo.append(iface);\r
31   iface->connectedFrom = this;\r
32   ConnectedInterface* asso1 = (ConnectedInterface*)associatedIface;\r
33   ConnectedInterface* asso2 = (ConnectedInterface*)(iface->associatedIface);\r
34   if ((asso1 != NULL) && (asso2 != NULL)) {\r
35     asso1->connectedTo.append(asso2);\r
36     asso2->connectedFrom = asso1;\r
37   }\r
38 }\r
39 \r
40 void ConnectedInterface::disconnectTo(ConnectedInterface *iface) {\r
41   \r
42   connectedTo.removeAll(iface);\r
43   iface->connectedFrom = NULL;\r
44   ConnectedInterface* asso1 = (ConnectedInterface*)associatedIface;\r
45   ConnectedInterface* asso2 = (ConnectedInterface*)(iface->associatedIface);\r
46   if ((asso1 != NULL) && (asso2 != NULL)) {\r
47     asso1->connectedTo.removeAll(asso2);\r
48     asso2->connectedFrom = NULL;\r
49   }\r
50 }\r
51 \r
52 \r
53 /*\r
54 bool ConnectedInterface::connectFrom(ConnectedInterface *iface) {\r
55   if (canConnectFrom(iface)) {\r
56     connectedFrom = iface;\r
57     return true;\r
58   }\r
59   return false;\r
60 }\r
61 */\r
62 \r
63 /* getConnectionToParentGroup() :\r
64    if an interface among connectedTo is an interface of the parent group\r
65    returns it.\r
66 */\r
67 ConnectedInterface* ConnectedInterface::getConnectionToParentGroup() {\r
68   foreach(ConnectedInterface *iface, connectedTo) {\r
69     if (owner->getParent() == iface->owner) {\r
70       return iface;\r
71     }\r
72   }\r
73   return NULL;\r
74 }\r
75 \r
76 /* getConnectionFromParentGroup() :\r
77    if connectedFrom is an interface of the parent group\r
78    returns it.\r
79 */\r
80 ConnectedInterface *ConnectedInterface::getConnectionFromParentGroup() {\r
81   if ((connectedFrom != NULL) && (owner->getParent() == connectedFrom->owner)) {\r
82     return connectedFrom;\r
83   }\r
84   return NULL;\r
85 }\r