| 103 | } |
| 104 | |
| 105 | void ServiceHooks::FilterServiceReferences(ModuleContext* mc, const std::string& service, |
| 106 | const std::string& filter, std::vector<ServiceReferenceBase>& refs) |
| 107 | { |
| 108 | std::vector<ServiceRegistrationBase> srl; |
| 109 | coreCtx->services.Get_unlocked(us_service_interface_iid<ServiceFindHook>(), srl); |
| 110 | if (!srl.empty()) |
| 111 | { |
| 112 | ShrinkableVector<ServiceReferenceBase> filtered(refs); |
| 113 | |
| 114 | std::sort(srl.begin(), srl.end()); |
| 115 | for (std::vector<ServiceRegistrationBase>::reverse_iterator fhrIter = srl.rbegin(), fhrEnd = srl.rend(); |
| 116 | fhrIter != fhrEnd; ++fhrIter) |
| 117 | { |
| 118 | ServiceReference<ServiceFindHook> sr = fhrIter->GetReference(); |
| 119 | ServiceFindHook* const fh = reinterpret_cast<ServiceFindHook*>(sr.d->GetService(GetModuleContext()->GetModule())); |
| 120 | if (fh != nullptr) |
| 121 | { |
| 122 | try |
| 123 | { |
| 124 | fh->Find(mc, service, filter, filtered); |
| 125 | } |
| 126 | catch (const std::exception& e) |
| 127 | { |
| 128 | MITK_WARN << "Failed to call find hook #" << sr.GetProperty(ServiceConstants::SERVICE_ID()).ToString() |
| 129 | << ": " << e.what(); |
| 130 | } |
| 131 | catch (...) |
| 132 | { |
| 133 | MITK_WARN << "Failed to call find hook #" << sr.GetProperty(ServiceConstants::SERVICE_ID()).ToString() |
| 134 | << ": unknown exception type"; |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | void ServiceHooks::FilterServiceEventReceivers(const ServiceEvent& evt, |
| 142 | ServiceListeners::ServiceListenerEntries& receivers) |
no test coverage detected