MCPcopy Create free account
hub / github.com/MITK/MITK / ModulePrivate

Method ModulePrivate

Modules/CppMicroServices/src/usModulePrivate.cpp:35–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33AtomicInt ModulePrivate::idCounter;
34
35ModulePrivate::ModulePrivate(Module* qq, CoreModuleContext* coreCtx,
36 ModuleInfo* info)
37 : coreCtx(coreCtx)
38 , info(*info)
39 , resourceContainer(info)
40 , moduleContext(nullptr)
41 , moduleActivator(nullptr)
42 , q(qq)
43{
44 // Check if the module provides a manifest.json file and if yes, parse it.
45 if (resourceContainer.IsValid())
46 {
47 ModuleResource manifestRes("/manifest.json", resourceContainer);
48 if (manifestRes)
49 {
50 ModuleResourceStream manifestStream(manifestRes);
51 try
52 {
53 moduleManifest.Parse(manifestStream);
54 }
55 catch (const std::exception& e)
56 {
57 MITK_ERROR << "Parsing of manifest.json for module " << info->location << " failed: " << e.what();
58 }
59 }
60 }
61
62 // Check if we got version information and validate the version identifier
63 if (moduleManifest.Contains(Module::PROP_VERSION()))
64 {
65 Any versionAny = moduleManifest.GetValue(Module::PROP_VERSION());
66 std::string errMsg;
67 try
68 {
69 version = ModuleVersion(versionAny.ToString());
70 }
71 catch (const std::exception& e)
72 {
73 errMsg = std::string("The version identifier is invalid: ") + e.what();
74 throw std::invalid_argument(std::string("The Json value for ") + Module::PROP_VERSION() + " for module " +
75 info->location + " is not valid: " + errMsg);
76 }
77 }
78
79 std::stringstream propId;
80 propId << this->info.id;
81 moduleManifest.SetValue(Module::PROP_ID(), propId.str());
82 moduleManifest.SetValue(Module::PROP_LOCATION(), this->info.location);
83 moduleManifest.SetValue(Module::PROP_NAME(), this->info.name);
84
85 if (moduleManifest.Contains(Module::PROP_AUTOLOAD_DIR()))
86 {
87 this->info.autoLoadDir = moduleManifest.GetValue(Module::PROP_AUTOLOAD_DIR()).ToString();
88 }
89 else
90 {
91 this->info.autoLoadDir = this->info.name;
92 moduleManifest.SetValue(Module::PROP_AUTOLOAD_DIR(), Any(this->info.autoLoadDir));

Callers

nothing calls this directly

Calls 8

whatMethod · 0.80
AnyClass · 0.70
IsValidMethod · 0.45
ParseMethod · 0.45
ContainsMethod · 0.45
GetValueMethod · 0.45
ToStringMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected