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.
|
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;
77 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>&) {
94 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>&) {
110 addCallbacks.emplace_back(std::forward<F>(add));
124 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>&) {
140 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>&) {
156 remCallbacks.emplace_back(std::forward<F>(remove));
171 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>&) {
188 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>&) {
205 setCallbacks.emplace_back(std::forward<F>(set));
214 std::shared_ptr<ServiceTracker<I>>
build() {
215 return ServiceTracker<I>::create(cCtx, std::move(name), std::move(versionRange), std::move(filter), std::move(setCallbacks), std::move(addCallbacks), std::move(remCallbacks));
218 const std::shared_ptr<celix_bundle_context_t> cCtx;
220 celix::Filter filter{};
221 std::string versionRange{};
222 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{};
223 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{};
224 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{};
242 BundleTrackerBuilder &
operator=(BundleTrackerBuilder &&) =
delete;
243 BundleTrackerBuilder(
const BundleTrackerBuilder &) =
delete;
244 BundleTrackerBuilder
operator=(
const BundleTrackerBuilder &) =
delete;
247 includeFrameworkBundle =
true;
258 onInstallCallbacks.push_back(std::move(callback));
269 onStartCallbacks.push_back(std::move(callback));
280 onStopCallbacks.push_back(std::move(callback));
289 std::shared_ptr<BundleTracker>
build() {
290 return BundleTracker::create(cCtx, includeFrameworkBundle, std::move(onInstallCallbacks), std::move(onStartCallbacks), std::move(onStopCallbacks));
293 const std::shared_ptr<celix_bundle_context_t> cCtx;
294 bool includeFrameworkBundle{
false};
295 std::vector<std::function<void(
const celix::Bundle&)>> onInstallCallbacks{};
296 std::vector<std::function<void(
const celix::Bundle&)>> onStartCallbacks{};
297 std::vector<std::function<void(
const celix::Bundle&)>> onStopCallbacks{};
313 explicit MetaTrackerBuilder(std::shared_ptr<celix_bundle_context_t> _cCtx, std::string _serviceName) :
314 cCtx{std::move(_cCtx)},
315 serviceName{std::move(_serviceName)} {}
317 MetaTrackerBuilder &
operator=(MetaTrackerBuilder &&) =
delete;
318 MetaTrackerBuilder(
const MetaTrackerBuilder &) =
delete;
319 MetaTrackerBuilder
operator=(
const MetaTrackerBuilder &) =
delete;
328 onTrackerCreated.emplace_back(std::move(cb));
339 onTrackerDestroyed.emplace_back(std::move(cb));
348 std::shared_ptr<MetaTracker>
build() {
349 return MetaTracker::create(cCtx, std::move(serviceName), std::move(onTrackerCreated), std::move(onTrackerDestroyed));
352 const std::shared_ptr<celix_bundle_context_t> cCtx;
353 std::string serviceName;
355 std::vector<std::function<void(
const ServiceTrackerInfo&)>> onTrackerDestroyed{};
static std::shared_ptr< ServiceTracker< I > > create(std::shared_ptr< celix_bundle_context_t > cCtx, std::string svcName, std::string 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:315
BundleTrackerBuilder & includeFrameworkBundleInCallback()
Definition: TrackerBuilders.h:246
BundleTrackerBuilder(std::shared_ptr< celix_bundle_context_t > _cCtx)
Definition: TrackerBuilders.h:240
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:155
ServiceTrackerBuilder & setFilter(celix::Filter f)
Set filter to be used to matching services.
Definition: TrackerBuilders.h:65
A trivial struct containing information about a service tracker.
Definition: Trackers.h:791
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:204
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:76
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:257
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:93
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:279
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:268
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:187
An installed bundle in the Celix framework.
Definition: Bundle.h:49
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:702
ServiceTrackerBuilder & setFilter(const std::string &f)
Set filter to be used to matching services.
Definition: TrackerBuilders.h:60
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:123
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:139
std::shared_ptr< BundleTracker > build()
"Builds" the bundle tracker and returns a BundleTracker.
Definition: TrackerBuilders.h:289
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:109
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:170
ServiceTrackerBuilder & operator=(ServiceTrackerBuilder &&)=delete
std::shared_ptr< ServiceTracker< I > > build()
"Builds" the service tracker and returns a ServiceTracker.
Definition: TrackerBuilders.h:214
Fluent builder API to track bundles.
Definition: TrackerBuilders.h:233