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

Method FilterModules

Modules/CppMicroServices/src/usModuleHooks.cpp:51–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void ModuleHooks::FilterModules(const ModuleContext* mc, std::vector<Module*>& modules) const
52{
53 std::vector<ServiceRegistrationBase> srl;
54 coreCtx->services.Get(us_service_interface_iid<ModuleFindHook>(), srl);
55 ShrinkableVector<Module*> filtered(modules);
56
57 std::sort(srl.begin(), srl.end());
58 for (std::vector<ServiceRegistrationBase>::reverse_iterator srBaseIter = srl.rbegin(), srBaseEnd = srl.rend();
59 srBaseIter != srBaseEnd; ++srBaseIter)
60 {
61 ServiceReference<ModuleFindHook> sr = srBaseIter->GetReference();
62 ModuleFindHook* const fh = reinterpret_cast<ModuleFindHook*>(sr.d->GetService(GetModuleContext()->GetModule()));
63 if (fh != nullptr)
64 {
65 try
66 {
67 fh->Find(mc, filtered);
68 }
69 catch (const std::exception& e)
70 {
71 MITK_WARN << "Failed to call Module FindHook #" << sr.GetProperty(ServiceConstants::SERVICE_ID()).ToString()
72 << ": " << e.what();
73 }
74 catch (...)
75 {
76 MITK_WARN << "Failed to call Module FindHook #" << sr.GetProperty(ServiceConstants::SERVICE_ID()).ToString()
77 << ": unknown exception type";
78 }
79 sr.d->UngetService(GetModuleContext()->GetModule(), false);
80 }
81 }
82}
83
84void ModuleHooks::FilterModuleEventReceivers(const ModuleEvent& evt,
85 ServiceListeners::ModuleListenerMap& moduleListeners)

Callers 2

FilterModuleMethod · 0.95
GetModulesMethod · 0.80

Calls 12

GetModuleContextFunction · 0.85
whatMethod · 0.80
GetMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetReferenceMethod · 0.45
GetServiceMethod · 0.45
GetModuleMethod · 0.45
FindMethod · 0.45
ToStringMethod · 0.45
GetPropertyMethod · 0.45
UngetServiceMethod · 0.45

Tested by

no test coverage detected