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

Method addModuleFromJson

libchigraph/src/Context.cpp:439–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437}
438
439Result Context::addModuleFromJson(const fs::path& fullName, const nlohmann::json& json,
440 GraphModule** toFill) {
441 Result res;
442
443 auto scopedCtx = res.addScopedContext({{"Requested Module Name", fullName.string()}});
444
445 // make sure it's not already added
446 {
447 auto mod = moduleByFullName(fullName);
448 if (mod != nullptr) {
449 if (toFill != nullptr) {
450 auto casted = dynamic_cast<GraphModule*>(mod);
451 if (casted != nullptr) { *toFill = casted; }
452 }
453 return {};
454 }
455 }
456
457 // Create the module
458 GraphModule* jMod = nullptr;
459 res += jsonToGraphModule(*this, json, fullName, &jMod);
460 if (toFill != nullptr) { *toFill = jMod; }
461
462 // if we failed, remove the module
463 if (!res) { unloadModule(jMod->fullName()); }
464
465 return res;
466}
467
468bool Context::addModule(std::unique_ptr<ChiModule> modToAdd) noexcept {
469 assert(modToAdd != nullptr);

Callers 1

runFunction · 0.80

Calls 3

jsonToGraphModuleFunction · 0.85
addScopedContextMethod · 0.80
fullNameMethod · 0.80

Tested by

no test coverage detected