| 62 | } |
| 63 | |
| 64 | Result GraphFunction::insertNode(std::unique_ptr<NodeType> type, float x, float y, |
| 65 | boost::uuids::uuid id, NodeInstance** toFill) { |
| 66 | // invalidate the cache |
| 67 | module().updateLastEditTime(); |
| 68 | |
| 69 | Result res; |
| 70 | |
| 71 | // make sure the ID doesn't exist |
| 72 | if (nodes().find(id) != nodes().end()) { |
| 73 | res.addEntry("E47", "Cannot have two nodes with the same ID", |
| 74 | {{"Requested ID", boost::uuids::to_string(id)}}); |
| 75 | return res; |
| 76 | } |
| 77 | |
| 78 | auto ptr = std::make_unique<NodeInstance>(this, std::move(type), x, y, id); |
| 79 | |
| 80 | auto emplaced = mNodes.emplace(id, std::move(ptr)).first; |
| 81 | |
| 82 | if (toFill != nullptr) { *toFill = emplaced->second.get(); } |
| 83 | |
| 84 | return res; |
| 85 | } |
| 86 | |
| 87 | std::vector<NodeInstance*> GraphFunction::nodesWithType(const boost::filesystem::path& module, |
| 88 | boost::string_view name) const noexcept { |
no test coverage detected