| 184 | } |
| 185 | |
| 186 | Result connectExec(NodeInstance& lhs, size_t lhsConnID, NodeInstance& rhs, size_t rhsConnID) { |
| 187 | Result res = {}; |
| 188 | |
| 189 | assert(&lhs.function() == &rhs.function()); |
| 190 | |
| 191 | lhs.module().updateLastEditTime(); |
| 192 | |
| 193 | // make sure the connection exists |
| 194 | if (lhsConnID >= lhs.outputExecConnections.size()) { |
| 195 | auto execOutputs = nlohmann::json::array(); |
| 196 | for (auto& output : lhs.type().execOutputs()) { execOutputs.push_back(output); } |
| 197 | |
| 198 | res.addEntry("E22", "Output exec connection doesn't exist in node", |
| 199 | {{"Requested ID", lhsConnID}, |
| 200 | {"Node Type", lhs.type().qualifiedName()}, |
| 201 | {"Node Output Exec Connections", execOutputs}}); |
| 202 | } |
| 203 | if (rhsConnID >= rhs.inputExecConnections.size()) { |
| 204 | auto execInputs = nlohmann::json::array(); |
| 205 | for (auto& output : rhs.type().execInputs()) { execInputs.push_back(output); } |
| 206 | |
| 207 | res.addEntry("E23", "Input exec connection doesn't exist in node", |
| 208 | {{"Requested ID", lhsConnID}, |
| 209 | {"Node Type", rhs.type().qualifiedName()}, |
| 210 | {"Node Input Exec Connections", execInputs} |
| 211 | |
| 212 | }); |
| 213 | } |
| 214 | |
| 215 | if (!res) { return res; } |
| 216 | // if we are replacing a connection, disconnect it |
| 217 | if (lhs.outputExecConnections[lhsConnID].first != nullptr) { |
| 218 | res += disconnectExec(lhs, lhsConnID); |
| 219 | if (!res) { return res; } |
| 220 | } |
| 221 | |
| 222 | // connect it! |
| 223 | lhs.outputExecConnections[lhsConnID] = {&rhs, rhsConnID}; |
| 224 | rhs.inputExecConnections[rhsConnID].emplace_back(&lhs, lhsConnID); |
| 225 | |
| 226 | return res; |
| 227 | } |
| 228 | |
| 229 | Result disconnectData(NodeInstance& lhs, size_t lhsConnID, NodeInstance& rhs) { |
| 230 | assert(&lhs.function() == &rhs.function()); |
no test coverage detected