MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / GetService

Method GetService

framework/src/bundle/BundleContext.cpp:243–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241 }
242
243 std::shared_ptr<void>
244 BundleContext::GetService(ServiceReferenceBase const& reference)
245 {
246 if (!reference)
247 {
248 throw std::invalid_argument("Default constructed ServiceReference is not a "
249 "valid input to GetService()");
250 }
251
252 if (!d)
253 {
254 throw cppmicroservices::IllegalStateException("The bundle context is no longer valid");
255 }
256
257 d->CheckValid();
258 auto b = GetAndCheckBundlePrivate(d);
259 auto serviceHolder = new ServiceHolder<void>(b, reference, reference.d.Load()->GetService(b.get()), nullptr);
260 std::shared_ptr<ServiceHolder<void>> h(serviceHolder, CustomServiceDeleter { serviceHolder });
261 return std::shared_ptr<void>(h, h->service.get());
262 }
263
264 InterfaceMapConstPtr
265 BundleContext::GetService(ServiceReferenceU const& reference)

Callers 9

FilterBundlesMethod · 0.45
AddingServiceFunction · 0.45
StartFunction · 0.45
ServiceChangedFunction · 0.45
StartFunction · 0.45
StartFunction · 0.45
mainFunction · 0.45
PrintTimeMethod · 0.45

Calls 5

GetAndCheckBundlePrivateFunction · 0.85
CheckValidMethod · 0.80
getMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected