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.
26 #include "celix/Utils.h"
46 std::shared_ptr<celix_bundle_context_t> _cCtx,
47 std::shared_ptr<I> _svc,
49 bool _registerAsync = true,
50 bool _unregisterAsync = true) :
51 cCtx{std::move(_cCtx)},
53 name{std::move(_name)},
54 version{celix::typeVersion<I>()},
55 registerAsync{_registerAsync},
56 unregisterAsync{_unregisterAsync} {}
58 ServiceRegistrationBuilder&
operator=(ServiceRegistrationBuilder&&) =
delete;
59 ServiceRegistrationBuilder(
const ServiceRegistrationBuilder&) =
delete;
60 ServiceRegistrationBuilder
operator=(
const ServiceRegistrationBuilder&) =
delete;
91 for (
const auto& pair : props) {
92 properties.set(pair.first, pair.second);
103 onRegisteredCallbacks.emplace_back(std::move(callback));
113 onUnregisteredCallbacks.emplace_back(std::move(callback));
133 registerAsync = async;
156 unregisterAsync = async;
167 std::shared_ptr<ServiceRegistration>
build() {
173 std::move(properties),
176 std::move(onRegisteredCallbacks),
177 std::move(onUnregisteredCallbacks));
180 const std::shared_ptr<celix_bundle_context_t> cCtx;
181 std::shared_ptr<I> svc;
185 bool unregisterAsync;
187 std::vector<std::function<void(ServiceRegistration&)>> onRegisteredCallbacks{};
188 std::vector<std::function<void(ServiceRegistration&)>> onUnregisteredCallbacks{};
ServiceRegistrationBuilder & addProperty(const std::string &key, T &&value)
Add a property to the service properties.
Definition: ServiceRegistrationBuilder.h:75
The bundle context is used to interact with the Celix framework.
Definition: BundleContext.h:53
ServiceRegistrationBuilder & setUnregisterAsync(bool async)
Configure if the service un-registration will be done synchronized or asynchronized.
Definition: ServiceRegistrationBuilder.h:155
ServiceRegistrationBuilder & setVersion(std::string v)
Set the service version.
Definition: ServiceRegistrationBuilder.h:67
ServiceRegistrationBuilder & addOnRegistered(std::function< void(ServiceRegistration &)> callback)
Adds an on registered callback for the service registration.
Definition: ServiceRegistrationBuilder.h:102
A registered service.
Definition: ServiceRegistration.h:54
ServiceRegistrationBuilder & addProperties(const celix::Properties &props)
Add the properties to the service properties.
Definition: ServiceRegistrationBuilder.h:90
Fluent builder API to build a new service registration for a service.
Definition: ServiceRegistrationBuilder.h:38
ServiceRegistrationBuilder & operator=(ServiceRegistrationBuilder &&)=delete
ServiceRegistrationBuilder & addOnUnregistered(std::function< void(ServiceRegistration &)> callback)
Adds an on unregistered callback for the service registration.
Definition: ServiceRegistrationBuilder.h:112
ServiceRegistrationBuilder & setProperties(celix::Properties p)
Set the service properties.
Definition: ServiceRegistrationBuilder.h:82
ServiceRegistrationBuilder & setRegisterAsync(bool async)
Configure if the service registration will be done synchronized or asynchronized.
Definition: ServiceRegistrationBuilder.h:132
std::shared_ptr< ServiceRegistration > build()
"Builds" the service registration and return a ServiceRegistration.
Definition: ServiceRegistrationBuilder.h:167
celix::Properties Properties
Definition: Properties.h:25
static std::shared_ptr< ServiceRegistration > create(std::shared_ptr< celix_bundle_context_t > cCtx, std::shared_ptr< void > svc, const std::string &name, const std::string &version, celix::Properties properties, bool registerAsync, bool unregisterAsync, std::vector< std::function< void(ServiceRegistration &)>> onRegisteredCallbacks, std::vector< std::function< void(ServiceRegistration &)>> onUnregisteredCallbacks)
Definition: ServiceRegistration.h:71