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

Private GIT Repository
corrected some warnings
[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       \r
11 }\r
12 \r
13 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
14   connectedFrom = NULL;\r
15   outputPattern = NULL;\r
16 }\r
17 \r
18 ConnectedInterface::~ConnectedInterface() {\r
19   if (outputPattern != NULL) delete outputPattern;\r
20 }\r
21 \r
22 /* NB/ became useless since disconnectTo does the job\r
23  \r
24 void ConnectedInterface::removeConnectedTo(ConnectedInterface *iface) {\r
25   connectedTo.removeAll(iface);\r
26 }\r
27 */\r
28 \r
29 void ConnectedInterface::clearConnections() {\r
30   connectedFrom = NULL;\r
31   connectedTo.clear();\r
32 }\r
33 \r
34 void ConnectedInterface::clearConnectedTo() {\r
35   connectedTo.clear();\r
36 }\r
37 \r
38 void ConnectedInterface::setOutputPattern(QList<char>* pattern) {\r
39   if (outputPattern != NULL) delete outputPattern;\r
40   outputPattern = pattern; \r
41 }\r
42 void ConnectedInterface::connectTo(ConnectedInterface *iface) {\r
43   \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
51   }\r
52 }\r
53 \r
54 void ConnectedInterface::disconnectTo(ConnectedInterface *iface) {\r
55   \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
63   }\r
64 }\r
65 \r
66 \r
67 /*\r
68 bool ConnectedInterface::connectFrom(ConnectedInterface *iface) {\r
69   if (canConnectFrom(iface)) {\r
70     connectedFrom = iface;\r
71     return true;\r
72   }\r
73   return false;\r
74 }\r
75 */\r
76 \r
77 /* getConnectionToParentGroup() :\r
78    if an interface among connectedTo is an interface of the parent group\r
79    returns it.\r
80 */\r
81 ConnectedInterface* ConnectedInterface::getConnectionToParentGroup() {\r
82   foreach(ConnectedInterface *iface, connectedTo) {\r
83     if (owner->getParent() == iface->owner) {\r
84       return iface;\r
85     }\r
86   }\r
87   return NULL;\r
88 }\r
89 \r
90 /* getConnectionFromParentGroup() :\r
91    if connectedFrom is an interface of the parent group\r
92    returns it.\r
93 */\r
94 ConnectedInterface *ConnectedInterface::getConnectionFromParentGroup() {\r
95   if ((connectedFrom != NULL) && (owner->getParent() == connectedFrom->owner)) {\r
96     return connectedFrom;\r
97   }\r
98   return NULL;\r
99 }\r