MCPcopy Create free account
hub / github.com/chigraph/chigraph / insertNode

Method insertNode

libchigraph/src/GraphFunction.cpp:64–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64Result 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
87std::vector<NodeInstance*> GraphFunction::nodesWithType(const boost::filesystem::path& module,
88 boost::string_view name) const noexcept {

Calls 5

updateLastEditTimeMethod · 0.80
endMethod · 0.80
addEntryMethod · 0.80
getMethod · 0.80
nodeTypeFromModuleMethod · 0.80

Tested by

no test coverage detected