Apache Celix  2.4.0
Apache Celix is a framework for C, C++14 and C++17 to develop dynamic modular software applications using component and in-process service-oriented programming.
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  CELIX_PROPERTIES_FOR_EACH(props, key) {
246  value = celix_properties_get(props, key, ""); //note. C++ does not allow nullptr entries for std::string
247  //std::cout << "got property " << key << "=" << value << "\n";
248  properties[key] = value;
249  }
250  }
251 
252  const I* srv = (const I*) service;
253 
254  fp(srv, std::move(properties));
255  return 0;
256 }
257 
258 
259 template<class T, class I>
261  this->runBuild();
262  this->wait();
263  return *this;
264 }
265 
266 template<class T, class I>
268  this->runBuild();
269  return *this;
270 }
271 
272 template<class T, class I>
273 ServiceDependency<T,I>::ServiceDependency(celix_dm_component_t* cCmp, const std::string &name) : TypedServiceDependency<T>(cCmp) {
274  if (!name.empty()) {
275  this->setName(name);
276  } else {
277  this->setupService();
278  }
279 }
280 
281 template<class T, class I>
283  std::string n = name;
284  if (n.empty()) {
285  n = celix::typeName<I>();
286  }
287 
288  const char* v = versionRange.empty() ? nullptr : versionRange.c_str();
289  celix_dmServiceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->filter.c_str());
290 }
291 
292 template<class T, class I>
294  name = _name;
295  setupService();
296  return *this;
297 }
298 
299 template<class T, class I>
301  filter = _filter;
302  setupService();
303  return *this;
304 }
305 
306 template<class T, class I>
308  versionRange = _versionRange;
309  setupService();
310  return *this;
311 }
312 
313 
314 template<class T, class I>
316  this->addCxxLanguageFilter = addLang;
317  setupService();
318  return *this;
319 }
320 
321 //set callbacks
322 template<class T, class I>
324  this->setCallbacks([this, set](I* srv, [[gnu::unused]] Properties&& props) {
325  T *cmp = this->componentInstance;
326  (cmp->*set)(srv);
327  });
328  return *this;
329 }
330 
331 template<class T, class I>
332 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(I* service, Properties&& properties)) {
333  this->setCallbacks([this, set](I* srv, Properties&& props) {
334  T *cmp = this->componentInstance;
335  (cmp->*set)(srv, std::move(props));
336  });
337  return *this;
338 }
339 
340 template<class T, class I>
341 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(std::function<void(I* service, Properties&& properties)> set) {
342  this->setFp = set;
343  this->setupCallbacks();
344  return *this;
345 }
346 
347 template<class T, class I>
348 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)) {
349  this->setCallbacks([this, set](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
350  T *cmp = this->componentInstance;
351  (cmp->*set)(std::move(service), properties);
352  });
353  return *this;
354 }
355 
356 template<class T, class I>
357 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) {
358  this->setFpUsingSharedPtr = std::move(set);
359  this->setupCallbacks();
360  return *this;
361 }
362 
363 template<class T, class I>
364 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(const std::shared_ptr<I>& service)) {
365  this->setCallbacks([this, set](const std::shared_ptr<I>& service) {
366  T *cmp = this->componentInstance;
367  (cmp->*set)(service);
368  });
369  return *this;
370 }
371 
372 template<class T, class I>
373 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(std::function<void(const std::shared_ptr<I>& service)> set) {
374  this->setCallbacks([set](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
375  set(service);
376  });
377  return *this;
378 }
379 
380 
381 //add remove callbacks
382 template<class T, class I>
384  void (T::*add)(I* service),
385  void (T::*remove)(I* service)) {
386  this->setCallbacks(
387  [this, add](I* srv, [[gnu::unused]] Properties&& props) {
388  T *cmp = this->componentInstance;
389  (cmp->*add)(srv);
390  },
391  [this, remove](I* srv, [[gnu::unused]] Properties&& props) {
392  T *cmp = this->componentInstance;
393  (cmp->*remove)(srv);
394  }
395  );
396  return *this;
397 }
398 
399 template<class T, class I>
401  void (T::*add)(I* service, Properties&& properties),
402  void (T::*remove)(I* service, Properties&& properties)
403 ) {
404  this->setCallbacks(
405  [this, add](I* srv, Properties&& props) {
406  T *cmp = this->componentInstance;
407  (cmp->*add)(srv, std::move(props));
408  },
409  [this, remove](I* srv, Properties&& props) {
410  T *cmp = this->componentInstance;
411  (cmp->*remove)(srv, std::move(props));
412  }
413  );
414  return *this;
415 }
416 
417 
418 template<class T, class I>
420  std::function<void(I* service, Properties&& properties)> add,
421  std::function<void(I* service, Properties&& properties)> remove) {
422  this->addFp = add;
423  this->removeFp = remove;
424  this->setupCallbacks();
425  return *this;
426 }
427 
428 template<class T, class I>
430  void (T::*add)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties),
431  void (T::*remove)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)
432 ) {
433  this->setCallbacks(
434  [this, add](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
435  T *cmp = this->componentInstance;
436  (cmp->*add)(service, properties);
437  },
438  [this, remove](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
439  T *cmp = this->componentInstance;
440  (cmp->*remove)(service, properties);
441  }
442  );
443  return *this;
444 }
445 
446 
447 template<class T, class I>
449  std::function<void(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)> add,
450  std::function<void(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)> remove) {
451  this->addFpUsingSharedPtr = std::move(add);
452  this->removeFpUsingSharedPtr = std::move(remove);
453  this->setupCallbacks();
454  return *this;
455 }
456 
457 template<class T, class I>
459  void (T::*add)(const std::shared_ptr<I>& service),
460  void (T::*remove)(const std::shared_ptr<I>& service)
461 ) {
462  this->setCallbacks(
463  [this, add](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
464  T *cmp = this->componentInstance;
465  (cmp->*add)(service);
466  },
467  [this, remove](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
468  T *cmp = this->componentInstance;
469  (cmp->*remove)(service);
470  }
471  );
472  return *this;
473 }
474 
475 
476 template<class T, class I>
478  std::function<void(const std::shared_ptr<I>& service)> add,
479  std::function<void(const std::shared_ptr<I>& service)> remove) {
480  this->setCallbacks(
481  [add](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
482  add(service);
483  },
484  [remove](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
485  remove(service);
486  }
487  );
488  return *this;
489 }
490 
491 
492 template<class T, class I>
494  celix_dmServiceDependency_setRequired(this->cServiceDependency(), req);
495  return *this;
496 }
497 
498 template<class T, class I>
500  this->setDepStrategy(strategy);
501  return *this;
502 }
503 
504 template<class T, class I>
505 int ServiceDependency<T,I>::invokeCallback(std::function<void(I*, Properties&&)> fp, const celix_properties_t *props, const void* service) {
506  I *svc = (I*)service;
507 
508  Properties properties {};
509  const char* key {nullptr};
510  const char* value {nullptr};
511 
512  if (props != nullptr) {
513  CELIX_PROPERTIES_FOR_EACH(props, key) {
514  value = celix_properties_get(props, key, "");
515  //std::cout << "got property " << key << "=" << value << "\n";
516  properties[key] = value;
517  }
518  }
519 
520  fp(svc, std::move(properties)); //explicit move of lvalue properties.
521  return 0;
522 }
523 
524 template<class T, class I>
526  int(*cset)(void*, void *, const celix_properties_t*) {nullptr};
527  int(*cadd)(void*, void *, const celix_properties_t*) {nullptr};
528  int(*crem)(void*, void *, const celix_properties_t*) {nullptr};
529 
530  if (setFp || setFpUsingSharedPtr) {
531  cset = [](void* handle, void* rawSvc, const celix_properties_t* rawProps) -> int {
532  int rc = 0;
533  auto dep = (ServiceDependency<T,I>*) handle;
534  if (dep->setFp) {
535  rc = dep->invokeCallback(dep->setFp, rawProps, rawSvc);
536  }
537  if (dep->setFpUsingSharedPtr) {
538  auto svcId = dep->setService.second ? dep->setService.second->getAsLong(celix::SERVICE_ID, -1) : -1;
539  std::weak_ptr<I> replacedSvc = dep->setService.first;
540  std::weak_ptr<const celix::Properties> replacedProps = dep->setService.second;
541  auto svc = std::shared_ptr<I>{static_cast<I*>(rawSvc), [](I*){/*nop*/}};
542  auto props = rawProps ? celix::Properties::wrap(rawProps) : nullptr;
543  dep->setService = std::make_pair(std::move(svc), std::move(props));
544  dep->setFpUsingSharedPtr(dep->setService.first, dep->setService.second);
545  dep->waitForExpired(replacedSvc, svcId, "service pointer");
546  dep->waitForExpired(replacedProps, svcId, "service properties");
547  }
548  return rc;
549  };
550  }
551  if (addFp || addFpUsingSharedPtr) {
552  cadd = [](void* handle, void *rawSvc, const celix_properties_t* rawProps) -> int {
553  int rc = 0;
554  auto dep = (ServiceDependency<T,I>*) handle;
555  if (dep->addFp) {
556  rc = dep->invokeCallback(dep->addFp, rawProps, rawSvc);
557  }
558  if (dep->addFpUsingSharedPtr) {
559  auto props = celix::Properties::wrap(rawProps);
560  auto svc = std::shared_ptr<I>{static_cast<I*>(rawSvc), [](I*){/*nop*/}};
561  auto svcId = props->getAsLong(celix::SERVICE_ID, -1);
562  dep->addFpUsingSharedPtr(svc, props);
563  dep->addedServices.template emplace(svcId, std::make_pair(std::move(svc), std::move(props)));
564  }
565  return rc;
566  };
567  }
568  if (removeFp || removeFpUsingSharedPtr) {
569  crem = [](void* handle, void *rawSvc, const celix_properties_t* rawProps) -> int {
570  int rc = 0;
571  auto dep = (ServiceDependency<T,I>*) handle;
572  if (dep->removeFp) {
573  rc = dep->invokeCallback(dep->removeFp, rawProps, rawSvc);
574  }
575  if (dep->removeFpUsingSharedPtr) {
576  auto svcId = celix_properties_getAsLong(rawProps, celix::SERVICE_ID, -1);
577  auto it = dep->addedServices.find(svcId);
578  if (it != dep->addedServices.end()) {
579  std::weak_ptr<I> removedSvc = it->second.first;
580  std::weak_ptr<const celix::Properties> removedProps = it->second.second;
581  dep->removeFpUsingSharedPtr(it->second.first, it->second.second);
582  dep->addedServices.erase(it);
583  dep->template waitForExpired(removedSvc, svcId, "service pointer");
584  dep->template waitForExpired(removedProps, svcId, "service properties");
585  }
586  }
587  return rc;
588  };
589  }
590 
591  celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this);
593  std::memset(&opts, 0, sizeof(opts));
594  opts.setWithProps = cset;
595  opts.addWithProps = cadd;
596  opts.removeWithProps = crem;
597  celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts);
598 }
599 
600 template<class T, class I>
602  this->runBuild();
603  this->wait();
604  return *this;
605 }
606 
607 template<class T, class I>
609  this->runBuild();
610  return *this;
611 }
celix::dm::ServiceDependency::setStrategy
ServiceDependency< T, I > & setStrategy(DependencyUpdateStrategy strategy)
Definition: ServiceDependency_Impl.h:499
celix::dm::ServiceDependency::setCallbacks
ServiceDependency< T, I > & setCallbacks(void(T::*set)(I *service))
Definition: ServiceDependency_Impl.h:323
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::dm::ServiceDependency::setVersionRange
ServiceDependency< T, I > & setVersionRange(const std::string &versionRange)
Definition: ServiceDependency_Impl.h:307
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
Constants.h
celix::dm::CServiceDependency::build
CServiceDependency< T, I > & build()
Definition: ServiceDependency_Impl.h:260
celix::dm::CServiceDependency::buildAsync
CServiceDependency< T, I > & buildAsync()
Definition: ServiceDependency_Impl.h:267
celix::dm::BaseServiceDependency::cServiceDep
celix_dm_service_dependency_t * cServiceDep
Definition: ServiceDependency.h:53
celix::impl::waitForExpired
void waitForExpired(long bndId, std::weak_ptr< celix::BundleContext > &weakCtx, const char *name, std::weak_ptr< T > &observe)
Definition: BundleActivator.h:61
celix::dm::ServiceDependency::buildAsync
ServiceDependency< T, I > & buildAsync()
Definition: ServiceDependency_Impl.h:608
celix_bundleContext_waitForEvents
CELIX_FRAMEWORK_EXPORT void celix_bundleContext_waitForEvents(celix_bundle_context_t *ctx)
Wait until all Celix event for this bundle are completed.
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:315
celix_dmComponent_addServiceDependency
CELIX_FRAMEWORK_EXPORT celix_status_t celix_dmComponent_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep)
celix::dm::DependencyUpdateStrategy
DependencyUpdateStrategy
Definition: ServiceDependency.h:42
celix_framework.h
The Celix Framework API.
celix_dm_service_dependency_callback_options::setWithProps
celix_dm_service_update_with_props_fp setWithProps
Definition: celix_dm_service_dependency.h:51
celix_dmServiceDependency_setRequired
CELIX_FRAMEWORK_EXPORT celix_status_t celix_dmServiceDependency_setRequired(celix_dm_service_dependency_t *dependency, bool required)
celix_dm_service_dependency_callback_options::addWithProps
celix_dm_service_update_with_props_fp addWithProps
Definition: celix_dm_service_dependency.h:52
celix_framework_isCurrentThreadTheEventLoop
CELIX_FRAMEWORK_EXPORT bool celix_framework_isCurrentThreadTheEventLoop(celix_framework_t *fw)
Returns whether the current thread is the Celix framework event loop thread.
celix::dm::ServiceDependency::setName
ServiceDependency< T, I > & setName(const std::string &_name)
Definition: ServiceDependency_Impl.h:293
celix_dmServiceDependency_setCallbackHandle
CELIX_FRAMEWORK_EXPORT celix_status_t celix_dmServiceDependency_setCallbackHandle(celix_dm_service_dependency_t *dependency, void *handle)
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:273
celix_bundleContext_log
CELIX_FRAMEWORK_EXPORT void celix_bundleContext_log(const celix_bundle_context_t *ctx, celix_log_level_e level, const char *format,...) __attribute__((format(printf
Logs a message to Celix framework logger with the provided log level.
celix_dmServiceDependency_setService
CELIX_FRAMEWORK_EXPORT celix_status_t celix_dmServiceDependency_setService(celix_dm_service_dependency_t *dependency, const char *serviceName, const char *serviceVersionRange, const char *filter)
celix::dm::TypedServiceDependency
Definition: ServiceDependency.h:108
celix::dm::ServiceDependency::setRequired
ServiceDependency< T, I > & setRequired(bool req)
Definition: ServiceDependency_Impl.h:493
celix_dm_service_dependency_callback_options
Definition: celix_dm_service_dependency.h:45
celix_dmServiceDependency_destroy
CELIX_FRAMEWORK_EXPORT void celix_dmServiceDependency_destroy(celix_dm_service_dependency_t *dep)
celix::dm
Definition: Component.h:41
ServiceDependency.h
celix::dm::ServiceDependency::setFilter
ServiceDependency< T, I > & setFilter(const std::string &filter)
Definition: ServiceDependency_Impl.h:300
celix::dm::CServiceDependency::setFilter
CServiceDependency< T, I > & setFilter(const std::string &filter)
Definition: ServiceDependency_Impl.h:102
celix_dmComponent_getBundleContext
CELIX_FRAMEWORK_EXPORT celix_bundle_context_t * celix_dmComponent_getBundleContext(celix_dm_component_t *component)
celix_dmServiceDependency_setCallbacksWithOptions
CELIX_FRAMEWORK_EXPORT celix_status_t celix_dmServiceDependency_setCallbacksWithOptions(celix_dm_service_dependency_t *dependency, const celix_dm_service_dependency_callback_options_t *opts)
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_bundleContext_getFramework
CELIX_FRAMEWORK_EXPORT celix_framework_t * celix_bundleContext_getFramework(const celix_bundle_context_t *ctx)
celix::dm::ServiceDependency::build
ServiceDependency< T, I > & build()
Definition: ServiceDependency_Impl.h:601
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