Apache Celix  2.3.0
An implementation of the OSGi specification adapted to C and C++
ServiceDependency_Impl.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #include <vector>
21 #include <iostream>
22 #include <cstring>
23 #include <thread>
24 
25 #include "celix/Constants.h"
26 #include "celix_constants.h"
27 #include "celix_properties.h"
28 #include "celix_bundle_context.h"
29 #include "celix_framework.h"
30 #include "ServiceDependency.h"
31 
32 
33 using namespace celix::dm;
34 
35 
36 template<typename U>
37 inline void BaseServiceDependency::waitForExpired(std::weak_ptr<U> observe, long svcId, const char* observeType) {
38  auto start = std::chrono::system_clock::now();
39  while (!observe.expired()) {
40  auto now = std::chrono::system_clock::now();
41  auto durationInMilli = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
42  if (durationInMilli > warningTimoutForNonExpiredSvcObject) {
43  if (cCmp) {
44  auto* ctx = celix_dmComponent_getBundleContext(cCmp);
45  if (ctx) {
47  ctx,
48  CELIX_LOG_LEVEL_WARNING,
49  "celix::dm::ServiceDependency: Cannot remove %s associated with service.id %li, because it is still in use. Current shared_ptr use count is %i",
50  observeType,
51  svcId,
52  (int)observe.use_count());
53  }
54  }
55  start = now;
56  }
57  std::this_thread::sleep_for(std::chrono::milliseconds{50});
58  }
59 }
60 
62  bool alreadyAdded = depAddedToCmp.exchange(true);
63  if (!alreadyAdded) {
65  }
66 }
67 
68 inline void BaseServiceDependency::wait() const {
69  if (cCmp) {
70  auto* ctx = celix_dmComponent_getBundleContext(cCmp);
71  auto* fw = celix_bundleContext_getFramework(ctx);
74  } else {
75  celix_bundleContext_log(ctx, CELIX_LOG_LEVEL_WARNING,
76  "BaseServiceDependency::wait: Cannot wait for Celix event queue on the Celix event queue thread! "
77  "Use async DepMan API instead.");
78  }
79  }
80 }
81 
83  if (!depAddedToCmp) {
85  }
86 }
87 
88 template<class T, typename I>
89 CServiceDependency<T,I>::CServiceDependency(celix_dm_component_t* cCmp, const std::string &name) : TypedServiceDependency<T>(cCmp) {
90  this->name = name;
91  this->setupService();
92 }
93 
94 template<class T, typename I>
95 CServiceDependency<T,I>& CServiceDependency<T,I>::setVersionRange(const std::string &serviceVersionRange) {
96  this->versionRange = serviceVersionRange;
97  this->setupService();
98  return *this;
99 }
100 
101 template<class T, typename I>
103  filter = _filter;
104  this->setupService();
105  return *this;
106 }
107 
108 template<class T, typename I>
110  const char* cversion = this->versionRange.empty() ? nullptr : versionRange.c_str();
111  const char* cfilter = filter.empty() ? nullptr : filter.c_str();
112  celix_dmServiceDependency_setService(this->cServiceDependency(), this->name.c_str(), cversion, cfilter);
113 }
114 
115 template<class T, typename I>
117  celix_serviceDependency_setAddCLanguageFilter(this->cServiceDependency(), addLang);
118  this->setupService();
119  return *this;
120 }
121 
122 template<class T, typename I>
124  celix_dmServiceDependency_setRequired(this->cServiceDependency(), req);
125  return *this;
126 }
127 
128 template<class T, typename I>
130  this->setDepStrategy(strategy);
131  return *this;
132 }
133 
134 //set callbacks
135 template<class T, typename I>
137  this->setCallbacks([this, set](const I* service, [[gnu::unused]] Properties&& properties) {
138  T *cmp = this->componentInstance;
139  (cmp->*set)(service);
140  });
141  return *this;
142 }
143 
144 template<class T, typename I>
145 CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(void (T::*set)(const I* service, Properties&& properties)) {
146  this->setCallbacks([this, set](const I* service, Properties&& properties) {
147  T *cmp = this->componentInstance;
148  (cmp->*set)(service, std::move(properties));
149  });
150  return *this;
151 }
152 
153 template<class T, typename I>
154 CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(std::function<void(const I* service, Properties&& properties)> set) {
155  this->setFp = set;
156  this->setupCallbacks();
157  return *this;
158 }
159 
160 //add remove callbacks
161 template<class T, typename I>
163  void (T::*add)(const I* service),
164  void (T::*remove)(const I* service)) {
165  this->setCallbacks(
166  [this, add](const I* service, [[gnu::unused]] Properties&& properties) {
167  T *cmp = this->componentInstance;
168  (cmp->*add)(service);
169  },
170  [this, remove](const I* service, [[gnu::unused]] Properties&& properties) {
171  T *cmp = this->componentInstance;
172  (cmp->*remove)(service);
173  }
174  );
175  return *this;
176 }
177 
178 template<class T, typename I>
180  void (T::*add)(const I* service, Properties&& properties),
181  void (T::*remove)(const I* service, Properties&& properties)
182 ) {
183  this->setCallbacks(
184  [this, add](const I* service, Properties&& properties) {
185  T *cmp = this->componentInstance;
186  (cmp->*add)(service, std::move(properties));
187  },
188  [this, remove](const I* service, Properties&& properties) {
189  T *cmp = this->componentInstance;
190  (cmp->*remove)(service, std::move(properties));
191  }
192  );
193  return *this;
194 }
195 
196 template<class T, typename I>
197 CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(std::function<void(const I* service, Properties&& properties)> add, std::function<void(const I* service, Properties&& properties)> remove) {
198  this->addFp = add;
199  this->removeFp = remove;
200  this->setupCallbacks();
201  return *this;
202 }
203 
204 
205 template<class T, typename I>
207  int(*cset)(void*, void *, const celix_properties_t*) {nullptr};
208  int(*cadd)(void*, void *, const celix_properties_t*) {nullptr};
209  int(*crem)(void*, void *, const celix_properties_t*) {nullptr};
210 
211  if (setFp) {
212  cset = [](void* handle, void *service, const celix_properties_t *props) -> int {
213  auto dep = (CServiceDependency<T,I>*) handle;
214  return dep->invokeCallback(dep->setFp, props, service);
215  };
216  }
217  if (addFp) {
218  cadd = [](void* handle, void *service, const celix_properties_t *props) -> int {
219  auto dep = (CServiceDependency<T,I>*) handle;
220  return dep->invokeCallback(dep->addFp, props, service);
221  };
222  }
223  if (removeFp) {
224  crem= [](void* handle, void *service, const celix_properties_t *props) -> int {
225  auto dep = (CServiceDependency<T,I>*) handle;
226  return dep->invokeCallback(dep->removeFp, props, service);
227  };
228  }
229  celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this);
231  std::memset(&opts, 0, sizeof(opts));
232  opts.addWithProps = cadd;
233  opts.removeWithProps = crem;
234  opts.setWithProps = cset;
235  celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts);
236 }
237 
238 template<class T, typename I>
239 int CServiceDependency<T,I>::invokeCallback(std::function<void(const I*, Properties&&)> fp, const celix_properties_t *props, const void* service) {
240  Properties properties {};
241  const char* key {nullptr};
242  const char* value {nullptr};
243 
244  if (props != nullptr) {
245  hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt)props);
246  while(hashMapIterator_hasNext(&iter)) {
247  key = (const char*) hashMapIterator_nextKey(&iter);
248  value = celix_properties_get(props, key, ""); //note. C++ does not allow nullptr entries for std::string
249  //std::cout << "got property " << key << "=" << value << "\n";
250  properties[key] = value;
251  }
252  }
253 
254  const I* srv = (const I*) service;
255 
256  fp(srv, std::move(properties));
257  return 0;
258 }
259 
260 
261 template<class T, class I>
263  this->runBuild();
264  this->wait();
265  return *this;
266 }
267 
268 template<class T, class I>
270  this->runBuild();
271  return *this;
272 }
273 
274 template<class T, class I>
275 ServiceDependency<T,I>::ServiceDependency(celix_dm_component_t* cCmp, const std::string &name) : TypedServiceDependency<T>(cCmp) {
276  if (!name.empty()) {
277  this->setName(name);
278  } else {
279  this->setupService();
280  }
281 }
282 
283 template<class T, class I>
285  std::string n = name;
286  if (n.empty()) {
287  n = celix::typeName<I>();
288  }
289 
290  const char* v = versionRange.empty() ? nullptr : versionRange.c_str();
291  celix_dmServiceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->filter.c_str());
292 }
293 
294 template<class T, class I>
296  name = _name;
297  setupService();
298  return *this;
299 }
300 
301 template<class T, class I>
303  filter = _filter;
304  setupService();
305  return *this;
306 }
307 
308 template<class T, class I>
310  versionRange = _versionRange;
311  setupService();
312  return *this;
313 }
314 
315 
316 template<class T, class I>
318  this->addCxxLanguageFilter = addLang;
319  setupService();
320  return *this;
321 }
322 
323 //set callbacks
324 template<class T, class I>
326  this->setCallbacks([this, set](I* srv, [[gnu::unused]] Properties&& props) {
327  T *cmp = this->componentInstance;
328  (cmp->*set)(srv);
329  });
330  return *this;
331 }
332 
333 template<class T, class I>
334 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(I* service, Properties&& properties)) {
335  this->setCallbacks([this, set](I* srv, Properties&& props) {
336  T *cmp = this->componentInstance;
337  (cmp->*set)(srv, std::move(props));
338  });
339  return *this;
340 }
341 
342 template<class T, class I>
343 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(std::function<void(I* service, Properties&& properties)> set) {
344  this->setFp = set;
345  this->setupCallbacks();
346  return *this;
347 }
348 
349 template<class T, class I>
350 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)) {
351  this->setCallbacks([this, set](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
352  T *cmp = this->componentInstance;
353  (cmp->*set)(std::move(service), properties);
354  });
355  return *this;
356 }
357 
358 template<class T, class I>
359 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(std::function<void(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)> set) {
360  this->setFpUsingSharedPtr = std::move(set);
361  this->setupCallbacks();
362  return *this;
363 }
364 
365 template<class T, class I>
366 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(const std::shared_ptr<I>& service)) {
367  this->setCallbacks([this, set](const std::shared_ptr<I>& service) {
368  T *cmp = this->componentInstance;
369  (cmp->*set)(service);
370  });
371  return *this;
372 }
373 
374 template<class T, class I>
375 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(std::function<void(const std::shared_ptr<I>& service)> set) {
376  this->setCallbacks([set](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
377  set(service);
378  });
379  return *this;
380 }
381 
382 
383 //add remove callbacks
384 template<class T, class I>
386  void (T::*add)(I* service),
387  void (T::*remove)(I* service)) {
388  this->setCallbacks(
389  [this, add](I* srv, [[gnu::unused]] Properties&& props) {
390  T *cmp = this->componentInstance;
391  (cmp->*add)(srv);
392  },
393  [this, remove](I* srv, [[gnu::unused]] Properties&& props) {
394  T *cmp = this->componentInstance;
395  (cmp->*remove)(srv);
396  }
397  );
398  return *this;
399 }
400 
401 template<class T, class I>
403  void (T::*add)(I* service, Properties&& properties),
404  void (T::*remove)(I* service, Properties&& properties)
405 ) {
406  this->setCallbacks(
407  [this, add](I* srv, Properties&& props) {
408  T *cmp = this->componentInstance;
409  (cmp->*add)(srv, std::move(props));
410  },
411  [this, remove](I* srv, Properties&& props) {
412  T *cmp = this->componentInstance;
413  (cmp->*remove)(srv, std::move(props));
414  }
415  );
416  return *this;
417 }
418 
419 
420 template<class T, class I>
422  std::function<void(I* service, Properties&& properties)> add,
423  std::function<void(I* service, Properties&& properties)> remove) {
424  this->addFp = add;
425  this->removeFp = remove;
426  this->setupCallbacks();
427  return *this;
428 }
429 
430 template<class T, class I>
432  void (T::*add)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties),
433  void (T::*remove)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)
434 ) {
435  this->setCallbacks(
436  [this, add](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
437  T *cmp = this->componentInstance;
438  (cmp->*add)(service, properties);
439  },
440  [this, remove](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
441  T *cmp = this->componentInstance;
442  (cmp->*remove)(service, properties);
443  }
444  );
445  return *this;
446 }
447 
448 
449 template<class T, class I>
451  std::function<void(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)> add,
452  std::function<void(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)> remove) {
453  this->addFpUsingSharedPtr = std::move(add);
454  this->removeFpUsingSharedPtr = std::move(remove);
455  this->setupCallbacks();
456  return *this;
457 }
458 
459 template<class T, class I>
461  void (T::*add)(const std::shared_ptr<I>& service),
462  void (T::*remove)(const std::shared_ptr<I>& service)
463 ) {
464  this->setCallbacks(
465  [this, add](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
466  T *cmp = this->componentInstance;
467  (cmp->*add)(service);
468  },
469  [this, remove](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
470  T *cmp = this->componentInstance;
471  (cmp->*remove)(service);
472  }
473  );
474  return *this;
475 }
476 
477 
478 template<class T, class I>
480  std::function<void(const std::shared_ptr<I>& service)> add,
481  std::function<void(const std::shared_ptr<I>& service)> remove) {
482  this->setCallbacks(
483  [add](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
484  add(service);
485  },
486  [remove](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
487  remove(service);
488  }
489  );
490  return *this;
491 }
492 
493 
494 template<class T, class I>
496  celix_dmServiceDependency_setRequired(this->cServiceDependency(), req);
497  return *this;
498 }
499 
500 template<class T, class I>
502  this->setDepStrategy(strategy);
503  return *this;
504 }
505 
506 template<class T, class I>
507 int ServiceDependency<T,I>::invokeCallback(std::function<void(I*, Properties&&)> fp, const celix_properties_t *props, const void* service) {
508  I *svc = (I*)service;
509 
510  Properties properties {};
511  const char* key {nullptr};
512  const char* value {nullptr};
513 
514  if (props != nullptr) {
515  hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt)props);
516  while(hashMapIterator_hasNext(&iter)) {
517  key = (const char*) hashMapIterator_nextKey(&iter);
518  value = celix_properties_get(props, key, "");
519  //std::cout << "got property " << key << "=" << value << "\n";
520  properties[key] = value;
521  }
522  }
523 
524  fp(svc, std::move(properties)); //explicit move of lvalue properties.
525  return 0;
526 }
527 
528 template<class T, class I>
530  int(*cset)(void*, void *, const celix_properties_t*) {nullptr};
531  int(*cadd)(void*, void *, const celix_properties_t*) {nullptr};
532  int(*crem)(void*, void *, const celix_properties_t*) {nullptr};
533 
534  if (setFp || setFpUsingSharedPtr) {
535  cset = [](void* handle, void* rawSvc, const celix_properties_t* rawProps) -> int {
536  int rc = 0;
537  auto dep = (ServiceDependency<T,I>*) handle;
538  if (dep->setFp) {
539  rc = dep->invokeCallback(dep->setFp, rawProps, rawSvc);
540  }
541  if (dep->setFpUsingSharedPtr) {
542  auto svcId = dep->setService.second ? dep->setService.second->getAsLong(celix::SERVICE_ID, -1) : -1;
543  std::weak_ptr<I> replacedSvc = dep->setService.first;
544  std::weak_ptr<const celix::Properties> replacedProps = dep->setService.second;
545  auto svc = std::shared_ptr<I>{static_cast<I*>(rawSvc), [](I*){/*nop*/}};
546  auto props = rawProps ? celix::Properties::wrap(rawProps) : nullptr;
547  dep->setService = std::make_pair(std::move(svc), std::move(props));
548  dep->setFpUsingSharedPtr(dep->setService.first, dep->setService.second);
549  dep->waitForExpired(replacedSvc, svcId, "service pointer");
550  dep->waitForExpired(replacedProps, svcId, "service properties");
551  }
552  return rc;
553  };
554  }
555  if (addFp || addFpUsingSharedPtr) {
556  cadd = [](void* handle, void *rawSvc, const celix_properties_t* rawProps) -> int {
557  int rc = 0;
558  auto dep = (ServiceDependency<T,I>*) handle;
559  if (dep->addFp) {
560  rc = dep->invokeCallback(dep->addFp, rawProps, rawSvc);
561  }
562  if (dep->addFpUsingSharedPtr) {
563  auto props = celix::Properties::wrap(rawProps);
564  auto svc = std::shared_ptr<I>{static_cast<I*>(rawSvc), [](I*){/*nop*/}};
565  auto svcId = props->getAsLong(celix::SERVICE_ID, -1);
566  dep->addFpUsingSharedPtr(svc, props);
567  dep->addedServices.template emplace(svcId, std::make_pair(std::move(svc), std::move(props)));
568  }
569  return rc;
570  };
571  }
572  if (removeFp || removeFpUsingSharedPtr) {
573  crem = [](void* handle, void *rawSvc, const celix_properties_t* rawProps) -> int {
574  int rc = 0;
575  auto dep = (ServiceDependency<T,I>*) handle;
576  if (dep->removeFp) {
577  rc = dep->invokeCallback(dep->removeFp, rawProps, rawSvc);
578  }
579  if (dep->removeFpUsingSharedPtr) {
580  auto svcId = celix_properties_getAsLong(rawProps, celix::SERVICE_ID, -1);
581  auto it = dep->addedServices.find(svcId);
582  if (it != dep->addedServices.end()) {
583  std::weak_ptr<I> removedSvc = it->second.first;
584  std::weak_ptr<const celix::Properties> removedProps = it->second.second;
585  dep->removeFpUsingSharedPtr(it->second.first, it->second.second);
586  dep->addedServices.erase(it);
587  dep->template waitForExpired(removedSvc, svcId, "service pointer");
588  dep->template waitForExpired(removedProps, svcId, "service properties");
589  }
590  }
591  return rc;
592  };
593  }
594 
595  celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this);
597  std::memset(&opts, 0, sizeof(opts));
598  opts.setWithProps = cset;
599  opts.addWithProps = cadd;
600  opts.removeWithProps = crem;
601  celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts);
602 }
603 
604 template<class T, class I>
606  this->runBuild();
607  this->wait();
608  return *this;
609 }
610 
611 template<class T, class I>
613  this->runBuild();
614  return *this;
615 }
celix::dm::ServiceDependency::setStrategy
ServiceDependency< T, I > & setStrategy(DependencyUpdateStrategy strategy)
Definition: ServiceDependency_Impl.h:501
celix_dmServiceDependency_setService
celix_status_t celix_dmServiceDependency_setService(celix_dm_service_dependency_t *dependency, const char *serviceName, const char *serviceVersionRange, const char *filter)
celix::dm::ServiceDependency::setCallbacks
ServiceDependency< T, I > & setCallbacks(void(T::*set)(I *service))
Definition: ServiceDependency_Impl.h:325
celix::dm::CServiceDependency::setVersionRange
CServiceDependency< T, I > & setVersionRange(const std::string &serviceVersionRange)
Definition: ServiceDependency_Impl.h:95
celix::dm::CServiceDependency
A service dependency for a component.
Definition: ServiceDependency.h:134
celix_dmServiceDependency_destroy
void celix_dmServiceDependency_destroy(celix_dm_service_dependency_t *dep)
celix::dm::ServiceDependency::setVersionRange
ServiceDependency< T, I > & setVersionRange(const std::string &versionRange)
Definition: ServiceDependency_Impl.h:309
celix_dm_service_dependency_callback_options::removeWithProps
celix_dm_service_update_with_props_fp removeWithProps
Definition: celix_dm_service_dependency.h:53
celix::dm::BaseServiceDependency::~BaseServiceDependency
virtual ~BaseServiceDependency() noexcept
Definition: ServiceDependency_Impl.h:82
celix::dm::CServiceDependency::setAddLanguageFilter
CServiceDependency< T, I > & setAddLanguageFilter(bool addLang)
Definition: ServiceDependency_Impl.h:116
celix::dm::CServiceDependency::CServiceDependency
CServiceDependency(celix_dm_component_t *cCmp, const std::string &name)
Definition: ServiceDependency_Impl.h:89
celix::dm::BaseServiceDependency::wait
void wait() const
Definition: ServiceDependency_Impl.h:68
celix::dm::CServiceDependency::setStrategy
CServiceDependency< T, I > & setStrategy(DependencyUpdateStrategy strategy)
Definition: ServiceDependency_Impl.h:129
celix_bundleContext_waitForEvents
void celix_bundleContext_waitForEvents(celix_bundle_context_t *ctx)
Wait until all Celix event for this bundle are completed.
Constants.h
celix::dm::CServiceDependency::build
CServiceDependency< T, I > & build()
Definition: ServiceDependency_Impl.h:262
celix_dmComponent_getBundleContext
celix_bundle_context_t * celix_dmComponent_getBundleContext(celix_dm_component_t *component)
celix::dm::CServiceDependency::buildAsync
CServiceDependency< T, I > & buildAsync()
Definition: ServiceDependency_Impl.h:269
celix::dm::BaseServiceDependency::cServiceDep
celix_dm_service_dependency_t * cServiceDep
Definition: ServiceDependency.h:53
celix::dm::ServiceDependency::buildAsync
ServiceDependency< T, I > & buildAsync()
Definition: ServiceDependency_Impl.h:612
celix::dm::BaseServiceDependency::runBuild
void runBuild()
Definition: ServiceDependency_Impl.h:61
celix::dm::ServiceDependency::setAddLanguageFilter
ServiceDependency< T, I > & setAddLanguageFilter(bool addLang)
Definition: ServiceDependency_Impl.h:317
celix::dm::DependencyUpdateStrategy
DependencyUpdateStrategy
Definition: ServiceDependency.h:42
celix_framework.h
celix_dm_service_dependency_callback_options::setWithProps
celix_dm_service_update_with_props_fp setWithProps
Definition: celix_dm_service_dependency.h:51
celix_dm_service_dependency_callback_options::addWithProps
celix_dm_service_update_with_props_fp addWithProps
Definition: celix_dm_service_dependency.h:52
celix::dm::ServiceDependency::setName
ServiceDependency< T, I > & setName(const std::string &_name)
Definition: ServiceDependency_Impl.h:295
celix_dmComponent_addServiceDependency
celix_status_t celix_dmComponent_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep)
celix_bundleContext_getFramework
celix_framework_t * celix_bundleContext_getFramework(const celix_bundle_context_t *ctx)
celix_dmServiceDependency_setRequired
celix_status_t celix_dmServiceDependency_setRequired(celix_dm_service_dependency_t *dependency, bool required)
celix::dm::CServiceDependency::setCallbacks
CServiceDependency< T, I > & setCallbacks(void(T::*set)(const I *service))
Definition: ServiceDependency_Impl.h:136
celix::dm::ServiceDependency::ServiceDependency
ServiceDependency(celix_dm_component_t *cCmp, const std::string &name)
Definition: ServiceDependency_Impl.h:275
celix::dm::TypedServiceDependency
Definition: ServiceDependency.h:108
celix::dm::ServiceDependency::setRequired
ServiceDependency< T, I > & setRequired(bool req)
Definition: ServiceDependency_Impl.h:495
celix_dm_service_dependency_callback_options
Definition: celix_dm_service_dependency.h:45
celix_framework_isCurrentThreadTheEventLoop
bool celix_framework_isCurrentThreadTheEventLoop(celix_framework_t *fw)
Returns whether the current thread is the Celix framework event loop thread.
celix::dm
Definition: Component.h:41
ServiceDependency.h
celix_bundleContext_log
void celix_bundleContext_log(const celix_bundle_context_t *ctx, celix_log_level_e level, const char *format,...)
Logs a message to Celix framework logger with the provided log level.
celix::dm::ServiceDependency::setFilter
ServiceDependency< T, I > & setFilter(const std::string &filter)
Definition: ServiceDependency_Impl.h:302
celix::dm::CServiceDependency::setFilter
CServiceDependency< T, I > & setFilter(const std::string &filter)
Definition: ServiceDependency_Impl.h:102
celix::dm::Properties
celix::Properties Properties
Definition: Properties.h:25
celix::SERVICE_ID
constexpr const char *const SERVICE_ID
Service property (named "service.id") identifying a service's registration number (of type long).
Definition: Constants.h:46
celix::dm::BaseServiceDependency::waitForExpired
void waitForExpired(std::weak_ptr< U > observe, long svcId, const char *observeType)
Definition: ServiceDependency_Impl.h:37
celix::dm::ServiceDependency::build
ServiceDependency< T, I > & build()
Definition: ServiceDependency_Impl.h:605
celix_dmServiceDependency_setCallbackHandle
celix_status_t celix_dmServiceDependency_setCallbackHandle(celix_dm_service_dependency_t *dependency, void *handle)
celix::dm::ServiceDependency
A service dependency for a component.
Definition: ServiceDependency.h:266
celix_bundle_context.h
celix::dm::CServiceDependency::setRequired
CServiceDependency< T, I > & setRequired(bool req)
Definition: ServiceDependency_Impl.h:123
celix_dmServiceDependency_setCallbacksWithOptions
celix_status_t celix_dmServiceDependency_setCallbacksWithOptions(celix_dm_service_dependency_t *dependency, const celix_dm_service_dependency_callback_options_t *opts)