Apache Celix
2.3.0
An implementation of the OSGi specification adapted to C and C++
|
Go to the documentation of this file.
34 #include "dm_service_dependency.h"
35 #include "celix_constants.h"
36 #include "celix_properties.h"
37 #include "celix/Utils.h"
40 namespace celix {
namespace dm {
49 const std::chrono::milliseconds warningTimoutForNonExpiredSvcObject{5000};
50 std::atomic<bool> depAddedToCmp{
false};
51 celix_dm_component_t* cCmp;
64 void waitForExpired(std::weak_ptr<U> observe,
long svcId,
const char* observeType);
84 bool isValid() const __attribute__((deprecated)) {
return true; }
133 template<
class T,
typename I>
209 void (T::*add)(
const I* service,
Properties&& properties),
210 void (T::*remove)(
const I* service,
Properties&& properties)
219 std::function<
void(
const I* service,
Properties&& properties)> add,
220 std::function<
void(
const I* service,
Properties&& properties)> remove
247 std::string filter {};
248 std::string versionRange {};
250 std::function<void(
const I* service,
Properties&& properties)> setFp{
nullptr};
251 std::function<void(
const I* service,
Properties&& properties)> addFp{
nullptr};
252 std::function<void(
const I* service,
Properties&& properties)> removeFp{
nullptr};
254 void setupCallbacks();
255 int invokeCallback(std::function<
void(
const I*,
Properties&&)> fp,
const celix_properties_t *props,
const void* service);
265 template<
class T,
class I>
360 void (T::*add)(I* service,
Properties&& properties),
361 void (T::*remove)(I* service,
Properties&& properties)
370 std::function<
void(I* service,
Properties&& properties)> add,
371 std::function<
void(I* service,
Properties&& properties)> remove
380 void (T::*add)(
const std::shared_ptr<I>& service,
const std::shared_ptr<const celix::Properties>& properties),
381 void (T::*remove)(
const std::shared_ptr<I>& service,
const std::shared_ptr<const celix::Properties>& properties));
389 std::function<
void(
const std::shared_ptr<I>& service,
const std::shared_ptr<const celix::Properties>& properties)> add,
390 std::function<
void(
const std::shared_ptr<I>& service,
const std::shared_ptr<const celix::Properties>& properties)> remove);
399 void (T::*add)(
const std::shared_ptr<I>& service),
400 void (T::*remove)(
const std::shared_ptr<I>& service));
408 std::function<
void(
const std::shared_ptr<I>& service)> add,
409 std::function<
void(
const std::shared_ptr<I>& service)> remove);
454 void setupCallbacks();
455 int invokeCallback(std::function<
void(I*,
Properties&&)> fp,
const celix_properties_t *props,
const void* service);
458 std::string filter {};
459 std::string versionRange {};
461 std::function<void(I* service,
Properties&& properties)> setFp{};
462 std::function<void(I* service,
Properties&& properties)> addFp{};
463 std::function<void(I* service,
Properties&& properties)> removeFp{};
465 std::function<void(
const std::shared_ptr<I>& service,
const std::shared_ptr<const celix::Properties>& properties)> setFpUsingSharedPtr{};
466 std::function<void(
const std::shared_ptr<I>& service,
const std::shared_ptr<const celix::Properties>& properties)> addFpUsingSharedPtr{};
467 std::function<void(
const std::shared_ptr<I>& service,
const std::shared_ptr<const celix::Properties>& properties)> removeFpUsingSharedPtr{};
470 std::unordered_map<long, std::pair<std::shared_ptr<I>, std::shared_ptr<const celix::Properties>>> addedServices{};
471 std::pair<std::shared_ptr<I>, std::shared_ptr<const celix::Properties>> setService{};
ServiceDependency< T, I > & setStrategy(DependencyUpdateStrategy strategy)
Definition: ServiceDependency_Impl.h:501
ServiceDependency< T, I > & setCallbacks(void(T::*set)(I *service))
Definition: ServiceDependency_Impl.h:325
CServiceDependency< T, I > & setVersionRange(const std::string &serviceVersionRange)
Definition: ServiceDependency_Impl.h:95
TypedServiceDependency & operator=(const TypedServiceDependency &)=delete
A service dependency for a component.
Definition: ServiceDependency.h:134
ServiceDependency< T, I > & setVersionRange(const std::string &versionRange)
Definition: ServiceDependency_Impl.h:309
Definition: ServiceDependency.h:47
virtual ~BaseServiceDependency() noexcept
Definition: ServiceDependency_Impl.h:82
~TypedServiceDependency() override=default
bool isValid() const __attribute__((deprecated))
Definition: ServiceDependency.h:84
celix_status_t celix_dmServiceDependency_setStrategy(celix_dm_service_dependency_t *dependency, celix_dm_service_dependency_strategy_t strategy)
CServiceDependency< T, I > & setAddLanguageFilter(bool addLang)
Definition: ServiceDependency_Impl.h:116
CServiceDependency(celix_dm_component_t *cCmp, const std::string &name)
Definition: ServiceDependency_Impl.h:89
void wait() const
Definition: ServiceDependency_Impl.h:68
CServiceDependency< T, I > & setStrategy(DependencyUpdateStrategy strategy)
Definition: ServiceDependency_Impl.h:129
TypedServiceDependency(celix_dm_component_t *cCmp)
Definition: ServiceDependency.h:113
CServiceDependency< T, I > & build()
Definition: ServiceDependency_Impl.h:262
ServiceDependency & operator=(const ServiceDependency &)=delete
T * componentInstance
Definition: ServiceDependency.h:111
CServiceDependency< T, I > & buildAsync()
Definition: ServiceDependency_Impl.h:269
celix_dm_service_dependency_t * cServiceDep
Definition: ServiceDependency.h:53
ServiceDependency< T, I > & buildAsync()
Definition: ServiceDependency_Impl.h:612
void runBuild()
Definition: ServiceDependency_Impl.h:61
celix_dm_service_dependency_t * celix_dmServiceDependency_create(void)
ServiceDependency< T, I > & setAddLanguageFilter(bool addLang)
Definition: ServiceDependency_Impl.h:317
DependencyUpdateStrategy
Definition: ServiceDependency.h:42
void setComponentInstance(T *cmp)
Definition: ServiceDependency.h:124
celix_dm_service_dependency_t * cServiceDependency() const
Definition: ServiceDependency.h:89
@ DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING
Definition: celix_dm_service_dependency.h:35
ServiceDependency< T, I > & setName(const std::string &_name)
Definition: ServiceDependency_Impl.h:295
CServiceDependency & operator=(const CServiceDependency &)=delete
CServiceDependency< T, I > & setCallbacks(void(T::*set)(const I *service))
Definition: ServiceDependency_Impl.h:136
ServiceDependency(celix_dm_component_t *cCmp, const std::string &name)
Definition: ServiceDependency_Impl.h:275
void setDepStrategy(DependencyUpdateStrategy strategy)
Definition: ServiceDependency.h:55
Definition: ServiceDependency.h:108
ServiceDependency< T, I > & setRequired(bool req)
Definition: ServiceDependency_Impl.h:495
BaseServiceDependency(celix_dm_component_t *c)
Definition: ServiceDependency.h:66
~ServiceDependency() override=default
ServiceDependency< T, I > & setFilter(const std::string &filter)
Definition: ServiceDependency_Impl.h:302
CServiceDependency< T, I > & setFilter(const std::string &filter)
Definition: ServiceDependency_Impl.h:102
@ DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
Definition: celix_dm_service_dependency.h:36
celix::Properties Properties
Definition: Properties.h:25
void waitForExpired(std::weak_ptr< U > observe, long svcId, const char *observeType)
Definition: ServiceDependency_Impl.h:37
ServiceDependency< T, I > & build()
Definition: ServiceDependency_Impl.h:605
A service dependency for a component.
Definition: ServiceDependency.h:266
~CServiceDependency() override=default
CServiceDependency< T, I > & setRequired(bool req)
Definition: ServiceDependency_Impl.h:123