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.
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;
67 #if __cplusplus >= 201703L //C++17 or higher
78 #if __cplusplus >= 201703L //C++17 or higher
100 for (
const auto& pair : props) {
101 properties.set(pair.first, pair.second);
112 onRegisteredCallbacks.emplace_back(std::move(callback));
122 onUnregisteredCallbacks.emplace_back(std::move(callback));
142 registerAsync = async;
165 unregisterAsync = async;
176 std::shared_ptr<ServiceRegistration>
build() {
182 std::move(properties),
185 std::move(onRegisteredCallbacks),
186 std::move(onUnregisteredCallbacks));
189 const std::shared_ptr<celix_bundle_context_t> cCtx;
190 std::shared_ptr<I> svc;
194 bool unregisterAsync;
196 std::vector<std::function<void(ServiceRegistration&)>> onRegisteredCallbacks{};
197 std::vector<std::function<void(ServiceRegistration&)>> onUnregisteredCallbacks{};
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:164
ServiceRegistrationBuilder & addProperty(std::string_view key, T &&value)
Add a property to the service properties.
Definition: ServiceRegistrationBuilder.h:80
ServiceRegistrationBuilder & addOnRegistered(std::function< void(ServiceRegistration &)> callback)
Adds an on registered callback for the service registration.
Definition: ServiceRegistrationBuilder.h:111
static std::shared_ptr< ServiceRegistration > create(std::shared_ptr< celix_bundle_context_t > cCtx, std::shared_ptr< void > svc, std::string_view name, std::string_view 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
A registered service.
Definition: ServiceRegistration.h:53
ServiceRegistrationBuilder & addProperties(const celix::Properties &props)
Add the properties to the service properties.
Definition: ServiceRegistrationBuilder.h:99
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:121
ServiceRegistrationBuilder & setProperties(celix::Properties p)
Set the service properties.
Definition: ServiceRegistrationBuilder.h:91
ServiceRegistrationBuilder & setRegisterAsync(bool async)
Configure if the service registration will be done synchronized or asynchronized.
Definition: ServiceRegistrationBuilder.h:141
std::shared_ptr< ServiceRegistration > build()
"Builds" the service registration and return a ServiceRegistration.
Definition: ServiceRegistrationBuilder.h:176
ServiceRegistrationBuilder & setVersion(std::string_view v)
Set the service version.
Definition: ServiceRegistrationBuilder.h:68
celix::Properties Properties
Definition: Properties.h:25