Apache Celix  latest
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::steady_clock::now();
39  while (!observe.expired()) {
40  auto now = std::chrono::steady_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_dmServiceDependency_setRequired(this->cServiceDependency(), req);
118  return *this;
119 }
120 
121 template<class T, typename I>
123  this->setDepStrategy(strategy);
124  return *this;
125 }
126 
127 //set callbacks
128 template<class T, typename I>
130  this->setCallbacks([this, set](const I* service, [[gnu::unused]] Properties&& properties) {
131  T *cmp = this->componentInstance;
132  (cmp->*set)(service);
133  });
134  return *this;
135 }
136 
137 template<class T, typename I>
138 CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(void (T::*set)(const I* service, Properties&& properties)) {
139  this->setCallbacks([this, set](const I* service, Properties&& properties) {
140  T *cmp = this->componentInstance;
141  (cmp->*set)(service, std::move(properties));
142  });
143  return *this;
144 }
145 
146 template<class T, typename I>
147 CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(std::function<void(const I* service, Properties&& properties)> set) {
148  this->setFp = set;
149  this->setupCallbacks();
150  return *this;
151 }
152 
153 //add remove callbacks
154 template<class T, typename I>
156  void (T::*add)(const I* service),
157  void (T::*remove)(const I* service)) {
158  this->setCallbacks(
159  [this, add](const I* service, [[gnu::unused]] Properties&& properties) {
160  T *cmp = this->componentInstance;
161  (cmp->*add)(service);
162  },
163  [this, remove](const I* service, [[gnu::unused]] Properties&& properties) {
164  T *cmp = this->componentInstance;
165  (cmp->*remove)(service);
166  }
167  );
168  return *this;
169 }
170 
171 template<class T, typename I>
173  void (T::*add)(const I* service, Properties&& properties),
174  void (T::*remove)(const I* service, Properties&& properties)
175 ) {
176  this->setCallbacks(
177  [this, add](const I* service, Properties&& properties) {
178  T *cmp = this->componentInstance;
179  (cmp->*add)(service, std::move(properties));
180  },
181  [this, remove](const I* service, Properties&& properties) {
182  T *cmp = this->componentInstance;
183  (cmp->*remove)(service, std::move(properties));
184  }
185  );
186  return *this;
187 }
188 
189 template<class T, typename I>
190 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) {
191  this->addFp = add;
192  this->removeFp = remove;
193  this->setupCallbacks();
194  return *this;
195 }
196 
197 
198 template<class T, typename I>
200  int(*cset)(void*, void *, const celix_properties_t*) {nullptr};
201  int(*cadd)(void*, void *, const celix_properties_t*) {nullptr};
202  int(*crem)(void*, void *, const celix_properties_t*) {nullptr};
203 
204  if (setFp) {
205  cset = [](void* handle, void *service, const celix_properties_t *props) -> int {
206  auto dep = (CServiceDependency<T,I>*) handle;
207  return dep->invokeCallback(dep->setFp, props, service);
208  };
209  }
210  if (addFp) {
211  cadd = [](void* handle, void *service, const celix_properties_t *props) -> int {
212  auto dep = (CServiceDependency<T,I>*) handle;
213  return dep->invokeCallback(dep->addFp, props, service);
214  };
215  }
216  if (removeFp) {
217  crem= [](void* handle, void *service, const celix_properties_t *props) -> int {
218  auto dep = (CServiceDependency<T,I>*) handle;
219  return dep->invokeCallback(dep->removeFp, props, service);
220  };
221  }
222  celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this);
224  std::memset(&opts, 0, sizeof(opts));
225  opts.addWithProps = cadd;
226  opts.removeWithProps = crem;
227  opts.setWithProps = cset;
228  celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts);
229 }
230 
231 template<class T, typename I>
232 int CServiceDependency<T,I>::invokeCallback(std::function<void(const I*, Properties&&)> fp, const celix_properties_t *props, const void* service) {
233  auto properties = Properties::copy(props);
234  const I* srv = (const I*) service;
235  fp(srv, std::move(properties));
236  return 0;
237 }
238 
239 
240 template<class T, class I>
242  this->runBuild();
243  this->wait();
244  return *this;
245 }
246 
247 template<class T, class I>
249  this->runBuild();
250  return *this;
251 }
252 
253 template<class T, class I>
254 ServiceDependency<T,I>::ServiceDependency(celix_dm_component_t* cCmp, const std::string &name) : TypedServiceDependency<T>(cCmp) {
255  if (!name.empty()) {
256  this->setName(name);
257  } else {
258  this->setupService();
259  }
260 }
261 
262 template<class T, class I>
264  std::string n = name;
265  if (n.empty()) {
266  n = celix::typeName<I>();
267  }
268 
269  const char* v = versionRange.empty() ? nullptr : versionRange.c_str();
270  celix_dmServiceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->filter.c_str());
271 }
272 
273 template<class T, class I>
275  name = _name;
276  setupService();
277  return *this;
278 }
279 
280 template<class T, class I>
282  filter = _filter;
283  setupService();
284  return *this;
285 }
286 
287 template<class T, class I>
289  versionRange = _versionRange;
290  setupService();
291  return *this;
292 }
293 
294 //set callbacks
295 template<class T, class I>
297  this->setCallbacks([this, set](I* srv, [[gnu::unused]] Properties&& props) {
298  T *cmp = this->componentInstance;
299  (cmp->*set)(srv);
300  });
301  return *this;
302 }
303 
304 template<class T, class I>
305 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(I* service, Properties&& properties)) {
306  this->setCallbacks([this, set](I* srv, Properties&& props) {
307  T *cmp = this->componentInstance;
308  (cmp->*set)(srv, std::move(props));
309  });
310  return *this;
311 }
312 
313 template<class T, class I>
314 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(std::function<void(I* service, Properties&& properties)> set) {
315  this->setFp = set;
316  this->setupCallbacks();
317  return *this;
318 }
319 
320 template<class T, class I>
321 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)) {
322  this->setCallbacks([this, set](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
323  T *cmp = this->componentInstance;
324  (cmp->*set)(std::move(service), properties);
325  });
326  return *this;
327 }
328 
329 template<class T, class I>
330 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) {
331  this->setFpUsingSharedPtr = std::move(set);
332  this->setupCallbacks();
333  return *this;
334 }
335 
336 template<class T, class I>
337 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(const std::shared_ptr<I>& service)) {
338  this->setCallbacks([this, set](const std::shared_ptr<I>& service) {
339  T *cmp = this->componentInstance;
340  (cmp->*set)(service);
341  });
342  return *this;
343 }
344 
345 template<class T, class I>
346 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(std::function<void(const std::shared_ptr<I>& service)> set) {
347  this->setCallbacks([set](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
348  set(service);
349  });
350  return *this;
351 }
352 
353 
354 //add remove callbacks
355 template<class T, class I>
357  void (T::*add)(I* service),
358  void (T::*remove)(I* service)) {
359  this->setCallbacks(
360  [this, add](I* srv, [[gnu::unused]] Properties&& props) {
361  T *cmp = this->componentInstance;
362  (cmp->*add)(srv);
363  },
364  [this, remove](I* srv, [[gnu::unused]] Properties&& props) {
365  T *cmp = this->componentInstance;
366  (cmp->*remove)(srv);
367  }
368  );
369  return *this;
370 }
371 
372 template<class T, class I>
374  void (T::*add)(I* service, Properties&& properties),
375  void (T::*remove)(I* service, Properties&& properties)
376 ) {
377  this->setCallbacks(
378  [this, add](I* srv, Properties&& props) {
379  T *cmp = this->componentInstance;
380  (cmp->*add)(srv, std::move(props));
381  },
382  [this, remove](I* srv, Properties&& props) {
383  T *cmp = this->componentInstance;
384  (cmp->*remove)(srv, std::move(props));
385  }
386  );
387  return *this;
388 }
389 
390 
391 template<class T, class I>
393  std::function<void(I* service, Properties&& properties)> add,
394  std::function<void(I* service, Properties&& properties)> remove) {
395  this->addFp = add;
396  this->removeFp = remove;
397  this->setupCallbacks();
398  return *this;
399 }
400 
401 template<class T, class I>
403  void (T::*add)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties),
404  void (T::*remove)(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)
405 ) {
406  this->setCallbacks(
407  [this, add](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
408  T *cmp = this->componentInstance;
409  (cmp->*add)(service, properties);
410  },
411  [this, remove](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties) {
412  T *cmp = this->componentInstance;
413  (cmp->*remove)(service, properties);
414  }
415  );
416  return *this;
417 }
418 
419 
420 template<class T, class I>
422  std::function<void(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)> add,
423  std::function<void(const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)> remove) {
424  this->addFpUsingSharedPtr = std::move(add);
425  this->removeFpUsingSharedPtr = std::move(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),
433  void (T::*remove)(const std::shared_ptr<I>& service)
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);
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);
443  }
444  );
445  return *this;
446 }
447 
448 
449 template<class T, class I>
451  std::function<void(const std::shared_ptr<I>& service)> add,
452  std::function<void(const std::shared_ptr<I>& service)> remove) {
453  this->setCallbacks(
454  [add](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
455  add(service);
456  },
457  [remove](const std::shared_ptr<I>& service, const std::shared_ptr<const celix::Properties>& /*properties*/) {
458  remove(service);
459  }
460  );
461  return *this;
462 }
463 
464 
465 template<class T, class I>
467  celix_dmServiceDependency_setRequired(this->cServiceDependency(), req);
468  return *this;
469 }
470 
471 template<class T, class I>
473  this->setDepStrategy(strategy);
474  return *this;
475 }
476 
477 template<class T, class I>
478 int ServiceDependency<T,I>::invokeCallback(std::function<void(I*, Properties&&)> fp, const celix_properties_t *props, const void* service) {
479  I *svc = (I*)service;
480  auto properties = celix::Properties::wrap(props);
481  fp(svc, std::move(properties)); //explicit move of lvalue properties.
482  return 0;
483 }
484 
485 template<class T, class I>
487  int(*cset)(void*, void *, const celix_properties_t*) {nullptr};
488  int(*cadd)(void*, void *, const celix_properties_t*) {nullptr};
489  int(*crem)(void*, void *, const celix_properties_t*) {nullptr};
490 
491  if (setFp || setFpUsingSharedPtr) {
492  cset = [](void* handle, void* rawSvc, const celix_properties_t* rawProps) -> int {
493  int rc = 0;
494  auto dep = (ServiceDependency<T,I>*) handle;
495  if (dep->setFp) {
496  rc = dep->invokeCallback(dep->setFp, rawProps, rawSvc);
497  }
498  if (dep->setFpUsingSharedPtr) {
499  auto svcId = dep->setService.second ? dep->setService.second->getAsLong(celix::SERVICE_ID, -1) : -1;
500  std::weak_ptr<I> replacedSvc = dep->setService.first;
501  std::weak_ptr<const celix::Properties> replacedProps = dep->setService.second;
502  auto svc = std::shared_ptr<I>{static_cast<I*>(rawSvc), [](I*){/*nop*/}};
503  auto props = rawProps ? std::make_shared<const celix::Properties>(celix::Properties::wrap(rawProps)) : nullptr;
504  dep->setService = std::make_pair(std::move(svc), std::move(props));
505  dep->setFpUsingSharedPtr(dep->setService.first, dep->setService.second);
506  dep->waitForExpired(replacedSvc, svcId, "service pointer");
507  dep->waitForExpired(replacedProps, svcId, "service properties");
508  }
509  return rc;
510  };
511  }
512  if (addFp || addFpUsingSharedPtr) {
513  cadd = [](void* handle, void *rawSvc, const celix_properties_t* rawProps) -> int {
514  int rc = 0;
515  auto dep = (ServiceDependency<T,I>*) handle;
516  if (dep->addFp) {
517  rc = dep->invokeCallback(dep->addFp, rawProps, rawSvc);
518  }
519  if (dep->addFpUsingSharedPtr) {
520  auto props = std::make_shared<const celix::Properties>(celix::Properties::wrap(rawProps));
521  auto svc = std::shared_ptr<I>{static_cast<I*>(rawSvc), [](I*){/*nop*/}};
522  auto svcId = props->getAsLong(celix::SERVICE_ID, -1);
523  dep->addFpUsingSharedPtr(svc, props);
524  dep->addedServices.template emplace(svcId, std::make_pair(std::move(svc), std::move(props)));
525  }
526  return rc;
527  };
528  }
529  if (removeFp || removeFpUsingSharedPtr) {
530  crem = [](void* handle, void *rawSvc, const celix_properties_t* rawProps) -> int {
531  int rc = 0;
532  auto dep = (ServiceDependency<T,I>*) handle;
533  if (dep->removeFp) {
534  rc = dep->invokeCallback(dep->removeFp, rawProps, rawSvc);
535  }
536  if (dep->removeFpUsingSharedPtr) {
537  auto svcId = celix_properties_getAsLong(rawProps, celix::SERVICE_ID, -1);
538  auto it = dep->addedServices.find(svcId);
539  if (it != dep->addedServices.end()) {
540  std::weak_ptr<I> removedSvc = it->second.first;
541  std::weak_ptr<const celix::Properties> removedProps = it->second.second;
542  dep->removeFpUsingSharedPtr(it->second.first, it->second.second);
543  dep->addedServices.erase(it);
544  dep->template waitForExpired(removedSvc, svcId, "service pointer");
545  dep->template waitForExpired(removedProps, svcId, "service properties");
546  }
547  }
548  return rc;
549  };
550  }
551 
552  celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this);
554  std::memset(&opts, 0, sizeof(opts));
555  opts.setWithProps = cset;
556  opts.addWithProps = cadd;
557  opts.removeWithProps = crem;
558  celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts);
559 }
560 
561 template<class T, class I>
563  this->runBuild();
564  this->wait();
565  return *this;
566 }
567 
568 template<class T, class I>
570  this->runBuild();
571  return *this;
572 }
celix::dm::ServiceDependency::setStrategy
ServiceDependency< T, I > & setStrategy(DependencyUpdateStrategy strategy)
Definition: ServiceDependency_Impl.h:472
celix::dm::ServiceDependency::setCallbacks
ServiceDependency< T, I > & setCallbacks(void(T::*set)(I *service))
Definition: ServiceDependency_Impl.h:296
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:288
celix_dm_service_dependency_callback_options::removeWithProps
celix_dm_service_update_with_props_fp removeWithProps
Definition: celix_dm_service_dependency.h:54
celix::dm::BaseServiceDependency::~BaseServiceDependency
virtual ~BaseServiceDependency() noexcept
Definition: ServiceDependency_Impl.h:82
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:122
Constants.h
celix::dm::CServiceDependency::build
CServiceDependency< T, I > & build()
Definition: ServiceDependency_Impl.h:241
celix::dm::CServiceDependency::buildAsync
CServiceDependency< T, I > & buildAsync()
Definition: ServiceDependency_Impl.h:248
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:569
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_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:52
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:53
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:274
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:129
celix::dm::ServiceDependency::ServiceDependency
ServiceDependency(celix_dm_component_t *cCmp, const std::string &name)
Definition: ServiceDependency_Impl.h:254
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:466
celix_dm_service_dependency_callback_options
Definition: celix_dm_service_dependency.h:46
celix_dmServiceDependency_destroy
CELIX_FRAMEWORK_EXPORT void celix_dmServiceDependency_destroy(celix_dm_service_dependency_t *dep)
celix::dm
Definition: Component.h:42
ServiceDependency.h
celix::dm::ServiceDependency::setFilter
ServiceDependency< T, I > & setFilter(const std::string &filter)
Definition: ServiceDependency_Impl.h:281
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:562
celix::dm::ServiceDependency
A service dependency for a component.
Definition: ServiceDependency.h:260
celix_bundle_context.h
celix::dm::CServiceDependency::setRequired
CServiceDependency< T, I > & setRequired(bool req)
Definition: ServiceDependency_Impl.h:116