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.
|
Go to the documentation of this file.
46 cCtx{std::move(_cCtx)},
47 name{std::move(_name)} {}
49 ServiceTrackerBuilder&
operator=(ServiceTrackerBuilder&&) =
delete;
50 ServiceTrackerBuilder(
const ServiceTrackerBuilder&) =
delete;
51 ServiceTrackerBuilder
operator=(
const ServiceTrackerBuilder&) =
delete;
60 #if __cplusplus >= 201703L //C++17 or higher
81 addCallbacks.emplace_back([add = std::forward<F>(add)](
const std::shared_ptr<I>& svc,
const std::shared_ptr<const celix::Properties>&,
const std::shared_ptr<const celix::Bundle>&) {
98 addCallbacks.emplace_back([add = std::forward<F>(add)](
const std::shared_ptr<I>& svc,
const std::shared_ptr<const celix::Properties>& props,
const std::shared_ptr<const celix::Bundle>&) {
114 addCallbacks.emplace_back(std::forward<F>(add));
128 remCallbacks.emplace_back([remove = std::forward<F>(remove)](
const std::shared_ptr<I>& svc,
const std::shared_ptr<const celix::Properties>&,
const std::shared_ptr<const celix::Bundle>&) {
144 remCallbacks.emplace_back([remove = std::forward<F>(remove)](
const std::shared_ptr<I>& svc,
const std::shared_ptr<const celix::Properties>& props,
const std::shared_ptr<const celix::Bundle>&) {
160 remCallbacks.emplace_back(std::forward<F>(remove));
175 setCallbacks.emplace_back([set = std::forward<F>(set)](
const std::shared_ptr<I>& svc,
const std::shared_ptr<const celix::Properties>&,
const std::shared_ptr<const celix::Bundle>&) {
192 setCallbacks.emplace_back([set = std::forward<F>(set)](
const std::shared_ptr<I>& svc,
const std::shared_ptr<const celix::Properties>& props,
const std::shared_ptr<const celix::Bundle>&) {
209 setCallbacks.emplace_back(std::forward<F>(set));
218 std::shared_ptr<ServiceTracker<I>>
build() {
219 return ServiceTracker<I>::create(cCtx, std::move(name), std::move(versionRange), std::move(filter), std::move(setCallbacks), std::move(addCallbacks), std::move(remCallbacks));
222 const std::shared_ptr<celix_bundle_context_t> cCtx;
224 celix::Filter filter{};
225 std::string versionRange{};
226 std::vector<std::function<void(
const std::shared_ptr<I>&,
const std::shared_ptr<const celix::Properties>&,
const std::shared_ptr<const celix::Bundle>&)>> setCallbacks{};
227 std::vector<std::function<void(
const std::shared_ptr<I>&,
const std::shared_ptr<const celix::Properties>&,
const std::shared_ptr<const celix::Bundle>&)>> addCallbacks{};
228 std::vector<std::function<void(
const std::shared_ptr<I>&,
const std::shared_ptr<const celix::Properties>&,
const std::shared_ptr<const celix::Bundle>&)>> remCallbacks{};
246 BundleTrackerBuilder &
operator=(BundleTrackerBuilder &&) =
delete;
247 BundleTrackerBuilder(
const BundleTrackerBuilder &) =
delete;
248 BundleTrackerBuilder
operator=(
const BundleTrackerBuilder &) =
delete;
251 includeFrameworkBundle =
true;
262 onInstallCallbacks.push_back(std::move(callback));
273 onStartCallbacks.push_back(std::move(callback));
284 onStopCallbacks.push_back(std::move(callback));
293 std::shared_ptr<BundleTracker>
build() {
294 return BundleTracker::create(cCtx, includeFrameworkBundle, std::move(onInstallCallbacks), std::move(onStartCallbacks), std::move(onStopCallbacks));
297 const std::shared_ptr<celix_bundle_context_t> cCtx;
298 bool includeFrameworkBundle{
false};
299 std::vector<std::function<void(
const celix::Bundle&)>> onInstallCallbacks{};
300 std::vector<std::function<void(
const celix::Bundle&)>> onStartCallbacks{};
301 std::vector<std::function<void(
const celix::Bundle&)>> onStopCallbacks{};
317 explicit MetaTrackerBuilder(std::shared_ptr<celix_bundle_context_t> _cCtx, std::string _serviceName) :
318 cCtx{std::move(_cCtx)},
319 serviceName{std::move(_serviceName)} {}
321 MetaTrackerBuilder &
operator=(MetaTrackerBuilder &&) =
delete;
322 MetaTrackerBuilder(
const MetaTrackerBuilder &) =
delete;
323 MetaTrackerBuilder
operator=(
const MetaTrackerBuilder &) =
delete;
332 onTrackerCreated.emplace_back(std::move(cb));
343 onTrackerDestroyed.emplace_back(std::move(cb));
352 std::shared_ptr<MetaTracker>
build() {
353 return MetaTracker::create(cCtx, std::move(serviceName), std::move(onTrackerCreated), std::move(onTrackerDestroyed));
356 const std::shared_ptr<celix_bundle_context_t> cCtx;
357 std::string serviceName;
359 std::vector<std::function<void(
const ServiceTrackerInfo&)>> onTrackerDestroyed{};
BundleTrackerBuilder & includeFrameworkBundleInCallback()
Definition: TrackerBuilders.h:250
BundleTrackerBuilder(std::shared_ptr< celix_bundle_context_t > _cCtx)
Definition: TrackerBuilders.h:244
The bundle context is used to interact with the Celix framework.
Definition: BundleContext.h:53
ServiceTrackerBuilder & addRemWithOwnerCallback(F &&remove)
Adds a remove callback function, which will be called - on the Celix event thread - when a service ma...
Definition: TrackerBuilders.h:159
ServiceTrackerBuilder & setFilter(std::string_view f)
Set filter to be used to matching services.
Definition: TrackerBuilders.h:61
ServiceTrackerBuilder & setFilter(celix::Filter f)
Set filter to be used to matching services.
Definition: TrackerBuilders.h:69
A trivial struct containing information about a service tracker.
Definition: Trackers.h:716
ServiceTrackerBuilder & addSetWithOwner(F &&set)
Adds a set callback function, which will be called - on the Celix event thread - when there is a new ...
Definition: TrackerBuilders.h:208
BundleTrackerBuilder & operator=(BundleTrackerBuilder &&)=delete
ServiceTrackerBuilder & addAddCallback(F &&add)
Adds a add callback function, which will be called - on the Celix event thread - when a new service m...
Definition: TrackerBuilders.h:80
BundleTrackerBuilder & addOnInstallCallback(std::function< void(const celix::Bundle &)> callback)
Adds a "on install" callback function, which will be called - on the Celix event thread - when a new ...
Definition: TrackerBuilders.h:261
ServiceTrackerBuilder & addAddWithPropertiesCallback(F &&add)
Adds a add callback function, which will be called - on the Celix event thread - when a new service m...
Definition: TrackerBuilders.h:97
Fluent builder API to track services.
Definition: TrackerBuilders.h:38
BundleTrackerBuilder & addOnStopCallback(std::function< void(const celix::Bundle &)> callback)
Adds a "on stop" callback function, which will be called - on the Celix event thread - when a new bun...
Definition: TrackerBuilders.h:283
BundleTrackerBuilder & addOnStartCallback(std::function< void(const celix::Bundle &)> callback)
Adds a "on start" callback function, which will be called - on the Celix event thread - when a new bu...
Definition: TrackerBuilders.h:272
ServiceTrackerBuilder & addSetWithPropertiesCallback(F &&set)
Adds a set callback function, which will be called - on the Celix event thread - when there is a new ...
Definition: TrackerBuilders.h:191
An installed bundle in the Celix framework.
Definition: Bundle.h:48
static std::shared_ptr< ServiceTracker< I > > create(std::shared_ptr< celix_bundle_context_t > cCtx, std::string_view svcName, std::string_view svcVersionRange, celix::Filter filter, std::vector< std::function< void(const std::shared_ptr< I > &, const std::shared_ptr< const celix::Properties > &, const std::shared_ptr< const celix::Bundle > &)>> setCallbacks, std::vector< std::function< void(const std::shared_ptr< I > &, const std::shared_ptr< const celix::Properties > &, const std::shared_ptr< const celix::Bundle > &)>> addCallbacks, std::vector< std::function< void(const std::shared_ptr< I > &, const std::shared_ptr< const celix::Properties > &, const std::shared_ptr< const celix::Bundle > &)>> remCallbacks)
Creates a new service tracker and opens the tracker.
Definition: Trackers.h:323
static std::shared_ptr< BundleTracker > create(std::shared_ptr< celix_bundle_context_t > cCtx, bool includeFrameworkBundle, std::vector< std::function< void(const celix::Bundle &)>> onInstallCallbacks, std::vector< std::function< void(const celix::Bundle &)>> onStartCallbacks, std::vector< std::function< void(const celix::Bundle &)>> onStopCallbacks)
Creates a new bundle tracker and opens the tracker.
Definition: Trackers.h:627
ServiceTrackerBuilder & addRemCallback(F &&remove)
Adds a remove callback function, which will be called - on the Celix event thread - when a service ma...
Definition: TrackerBuilders.h:127
ServiceTrackerBuilder & addRemWithPropertiesCallback(F &&remove)
Adds a remove callback function, which will be called - on the Celix event thread - when a service ma...
Definition: TrackerBuilders.h:143
std::shared_ptr< BundleTracker > build()
"Builds" the bundle tracker and returns a BundleTracker.
Definition: TrackerBuilders.h:293
ServiceTrackerBuilder & addAddWithOwnerCallback(F &&add)
Adds a add callback function, which will be called - on the Celix event thread - when a new service m...
Definition: TrackerBuilders.h:113
ServiceTrackerBuilder & addSetCallback(F &&set)
Adds a set callback function, which will be called - on the Celix event thread - when there is a new ...
Definition: TrackerBuilders.h:174
ServiceTrackerBuilder & operator=(ServiceTrackerBuilder &&)=delete
std::shared_ptr< ServiceTracker< I > > build()
"Builds" the service tracker and returns a ServiceTracker.
Definition: TrackerBuilders.h:218
Fluent builder API to track bundles.
Definition: TrackerBuilders.h:237