celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject celix git commit: CELIX-426: Adds BundleContext; :trackServicesWithOptions impl for C++.
Date Mon, 21 May 2018 18:22:46 GMT
Repository: celix
Updated Branches:
  refs/heads/feature/CELIX-426-cxx-api 51f62041c -> ad2ee8ed0


CELIX-426: Adds BundleContext;:trackServicesWithOptions impl for C++.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/ad2ee8ed
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/ad2ee8ed
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/ad2ee8ed

Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: ad2ee8ed02f61a22bdd2bd3dcd0c5485a57b42f6
Parents: 51f6204
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Mon May 21 20:22:04 2018 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Mon May 21 20:22:04 2018 +0200

----------------------------------------------------------------------
 framework/include/celix/BundleContext.h         |  49 ++-
 framework/include/celix/IServiceFactory.h       |   9 +-
 .../include/celix/impl/BundleContextImpl.h      | 302 +++++++++++--------
 framework/include/celix/impl/BundleImpl.h       |   4 +-
 framework/include/celix/impl/FrameworkImpl.h    |   6 +-
 5 files changed, 226 insertions(+), 144 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/ad2ee8ed/framework/include/celix/BundleContext.h
----------------------------------------------------------------------
diff --git a/framework/include/celix/BundleContext.h b/framework/include/celix/BundleContext.h
index 1ff37a9..077f661 100644
--- a/framework/include/celix/BundleContext.h
+++ b/framework/include/celix/BundleContext.h
@@ -17,9 +17,6 @@
  *under the License.
  */
 
-#ifndef CXX_CELIX_BUNDLECONTEXT_H
-#define CXX_CELIX_BUNDLECONTEXT_H
-
 #include <string>
 #include <vector>
 #include <functional>
@@ -27,6 +24,10 @@
 #include "celix/Constants.h"
 #include "celix/Properties.h"
 #include "celix/Bundle.h"
+#include "celix/IServiceFactory.h"
+
+#ifndef CXX_CELIX_BUNDLECONTEXT_H
+#define CXX_CELIX_BUNDLECONTEXT_H
 
 namespace celix {
 
@@ -41,9 +42,12 @@ namespace celix {
     struct ServiceRegistrationOptions {
         using type = I;
 
-        ServiceRegistrationOptions(I& _svc, const std::string& _serviceName) : svc{_svc},
serviceName{_serviceName} {};
+        ServiceRegistrationOptions(I& _svc, const std::string& _serviceName) : svc{&_svc},
serviceName{_serviceName} {};
+        ServiceRegistrationOptions(celix::IServiceFactory<I>& _factory, const std::string&
_serviceName) : factory{&_factory}, serviceName{_serviceName} {};
+
+        I *svc{nullptr};
+        celix::IServiceFactory<I> *factory{nullptr};
 
-        I& svc;
         const std::string serviceName;
 
         celix::Properties properties{};
@@ -61,7 +65,7 @@ namespace celix {
 
         std::string versionRange{};
         std::string filter{};
-        std::string lang{celix::Constants::SERVICE_CXX_LANG};
+        std::string serviceLanguage{celix::Constants::SERVICE_CXX_LANG};
     };
 
 
@@ -123,15 +127,25 @@ namespace celix {
         std::string resourceLenSymbol{};
     };
 
+    //opaque types to forward impl details to impl header
+    struct ServiceRegistrationEntry;
+    struct ServiceTrackingEntry;
+
     class BundleContext {
     public:
         virtual ~BundleContext(){};
 
         template<typename I>
-        long registerService(I *svc, const std::string &serviceName, Properties props
= {}) noexcept;
+        long registerService(I *svc, const std::string &serviceName, celix::Properties
props = {}) noexcept;
+
+        template<typename I>
+        long registerCService(I *svc, const std::string &serviceName, celix::Properties
props = {}) noexcept;
+
+        template<typename I>
+        long registerServiceFactory(celix::IServiceFactory<I> *svc, const std::string
&serviceName, celix::Properties props = {});
 
         template<typename I>
-        long registerCService(I *svc, const std::string &serviceName, Properties props
= {}) noexcept;
+        long registerCServiceFactory(celix::IServiceFactory<I> *svc, const std::string
&serviceName, celix::Properties props = {});
 
         template<typename I>
         long registerServiceWithOptions(const celix::ServiceRegistrationOptions<I>&
opts) noexcept;
@@ -140,7 +154,6 @@ namespace celix {
 
         virtual void unregisterService(long serviceId) noexcept = 0;
 
-        //register service factory
 
         /**
         * track service for the provided service type, service name, optional version range
and optional filter.
@@ -148,7 +161,6 @@ namespace celix {
         * If a new and higher ranking services the callback with be called again with the
new service.
         * If a service is removed a the callback with be called with next highest ranking
service or NULL as service.
         *
-        * @param ctx The bundle context.
         * @param serviceName The required service name to track
         * @param set is a required callback, which will be called when a new highest ranking
service is set.
         * @return the tracker id or < 0 if unsuccessful.
@@ -159,7 +171,6 @@ namespace celix {
         /**
          * track services for the provided serviceName and/or filter.
          *
-         * @param ctx The bundle context.
          * @param serviceName The required service name to track
          * @param add is a required callback, which will be called when a service is added
and initially for the existing service.
          * @param remove is a required callback, which will be called when a service is removed
@@ -168,10 +179,19 @@ namespace celix {
         template<typename I>
         long trackServices(const std::string &serviceName, std::function<void(I *svc)>
add, std::function<void(I *svc)> remove) noexcept;
 
-        //TODO trackService(s)WithOptions
         //TODO add trackCService(s) variants
 
         /**
+         * track services using the provided tracking options
+         *
+         * @param opts The tracking options
+         * @return the tracker id or < 0 if unsuccessful.
+         */
+        template<typename I>
+        long trackServicesWithOptions(const celix::ServiceTrackingOptions<I>& opts)
noexcept;
+
+
+        /**
          * Note use function by const reference. Only used during the call.
          * @param serviceId
          * @param I
@@ -254,10 +274,9 @@ namespace celix {
 
         virtual bool useBundle(long bundleId, const std::function<void(const celix::Bundle
&bnd)> &use) noexcept = 0;
     protected:
-        virtual long registerServiceInternal(const celix_service_registration_options_t &opts)
noexcept  = 0;
+        virtual long registerServiceInternal(celix::ServiceRegistrationEntry &&entry)
noexcept  = 0;
 
-        virtual long trackServiceInternal(const std::string &serviceName, std::function<void(void
*svc)> set) noexcept = 0;
-        virtual long trackServicesInternal(const std::string &serviceName, std::function<void(void
*svc)> add, std::function<void(void *svc)> remove) noexcept = 0;
+        virtual long trackServicesInternal(celix::ServiceTrackingEntry &&entry) noexcept
 = 0;
 
         virtual bool useServiceInternal(const std::string &serviceName, const std::function<void(void
*svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use)
noexcept = 0;
         virtual void useServicesInternal(const std::string &serviceName, const std::function<void(void
*svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use)
noexcept = 0;

http://git-wip-us.apache.org/repos/asf/celix/blob/ad2ee8ed/framework/include/celix/IServiceFactory.h
----------------------------------------------------------------------
diff --git a/framework/include/celix/IServiceFactory.h b/framework/include/celix/IServiceFactory.h
index 1adc8b5..1a00b47 100644
--- a/framework/include/celix/IServiceFactory.h
+++ b/framework/include/celix/IServiceFactory.h
@@ -24,10 +24,13 @@
 
 namespace celix {
 
-    typename<I>
+    template<typename I>
     class IServiceFactory {
-        virtual I* getService(IBundle &bundle) = 0;
-        virtual void ungetService(IBundle* bundle, I* svc) = 0;
+    public:
+        virtual ~IServiceFactory() = default;
+
+        virtual I* getService(const celix::Bundle &bundle, const celix::Properties &properties)
= 0;
+        virtual void ungetService(const celix::Bundle& bundle, const celix::Properties
&properties) = 0;
     };
 
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/ad2ee8ed/framework/include/celix/impl/BundleContextImpl.h
----------------------------------------------------------------------
diff --git a/framework/include/celix/impl/BundleContextImpl.h b/framework/include/celix/impl/BundleContextImpl.h
index 0afe73a..4600d03 100644
--- a/framework/include/celix/impl/BundleContextImpl.h
+++ b/framework/include/celix/impl/BundleContextImpl.h
@@ -29,34 +29,72 @@
 
 #include "celix/impl/BundleImpl.h"
 #include "celix/dm/DependencyManager.h"
+#include "celix_service_factory.h"
+
+namespace {
+    static celix::Properties createFromCProps(const celix_properties_t *c_props) {
+        celix::Properties result{};
+        const char *key = nullptr;
+        CELIX_PROPERTIES_FOR_EACH(const_cast<celix_properties_t*>(c_props), key) {
+            result[key] = celix_properties_get(c_props, key);
+        }
+        return result;
+    }
+
+    struct ServiceTrackingEntryFunctions {
+        std::function<void(void *)> set{};
+        std::function<void(void *, const celix::Properties &)> setWithProperties{};
+        std::function<void(void *, const celix::Properties &, const celix::Bundle
&)> setWithOwner{};
+
+        std::function<void(void *)> add{};
+        std::function<void(void *, const celix::Properties &)> addWithProperties{};
+        std::function<void(void *, const celix::Properties &, const celix::Bundle
&)> addWithOwner{};
+
+        std::function<void(void *)> remove{};
+        std::function<void(void *, const celix::Properties &)> removeWithProperties{};
+        std::function<void(void *, const celix::Properties &, const celix::Bundle
&)> removeWithOwner{};
+    };
+}
+
 
 namespace celix {
 
-    namespace impl {
+    struct ServiceRegistrationEntry {
+        long svcId{-1};
+        celix_service_factory_t factory{};
+        celix_service_registration_options_t cOpts{};
+    };
 
-        static celix::Properties createFromCProps(const celix_properties_t *c_props) {
-            celix::Properties result{};
-            const char *key = nullptr;
-            CELIX_PROPERTIES_FOR_EACH(const_cast<celix_properties_t*>(c_props), key)
{
-                result[key] = celix_properties_get(c_props, key);
-            }
-            return result;
-        }
+    struct ServiceTrackingEntry {
+        celix_service_tracking_options_t cOpts{};
+        std::unique_ptr<ServiceTrackingEntryFunctions> functions{nullptr};
+    };
+
+    namespace impl {
 
         class BundleContextImpl : public celix::BundleContext {
         public:
-            BundleContextImpl(bundle_context_t *ctx, celix::Framework& _fw) : c_ctx{ctx},
fw{_fw}, bnd{c_ctx}, dm{c_ctx} {}
+            BundleContextImpl(bundle_context_t *ctx, celix::Framework& _fw) : c_ctx(ctx),
fw(_fw), bnd(c_ctx), dm(c_ctx) {}
 
             virtual ~BundleContextImpl() {
                 //NOTE no need to destroy the c bundle context -> done by c framework
 
-                //clearing tracker entries
                 {
+                    //clearing service registration
+                    std::lock_guard<std::mutex> lock{this->mutex};
+                    for (auto &pair : this->registrationEntries) {
+                        celix_bundleContext_unregisterService(this->c_ctx, pair.first);
+                    }
+                    this->registrationEntries.clear();
+                }
+
+                {
+                    //clearing tracker entries
                     std::lock_guard<std::mutex> lock{this->mutex};
-                    for (auto &pair : this->trackEntries) {
+                    for (auto &pair : this->trackingEntries) {
                         celix_bundleContext_stopTracker(this->c_ctx, pair.first);
                     }
-                    this->trackEntries.clear();
+                    this->trackingEntries.clear();
                 }
 
                 this->c_ctx = nullptr;
@@ -86,9 +124,9 @@ namespace celix {
             void stopTracker(long trackerId) noexcept override {
                 std::lock_guard<std::mutex> lock{this->mutex};
                 celix_bundleContext_stopTracker(this->c_ctx, trackerId);
-                auto it = this->trackEntries.find(trackerId);
-                if (it != this->trackEntries.end()) {
-                    this->trackEntries.erase(it);
+                auto it = this->trackingEntries.find(trackerId);
+                if (it != this->trackingEntries.end()) {
+                    this->trackingEntries.erase(it);
                 }
             }
 
@@ -163,83 +201,24 @@ namespace celix {
             celix::dm::DependencyManager& getDependencyManager() noexcept override {
                 return this->dm;
             }
-
         protected:
 
-            long registerServiceInternal(const celix_service_registration_options_t &opts)
noexcept override {
-                return celix_bundleContext_registerServiceWithOptions(this->c_ctx, &opts);
-            }
-
-            long trackServiceInternal(const std::string &serviceName, std::function<void(void
*svc)> set) noexcept override  {
-                celix_service_tracking_options_t opts; //TODO why not ok? = CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
-                std::memset(&opts, 0, sizeof(opts));
-
-                auto c_set = [](void *handle, void *svc) {
-                    auto *entry = static_cast<TrackEntry*>(handle);
-                    //celix::Properties props = createFromCProps(c_props);
-                    //auto m_bnd = const_cast<celix_bundle_t *>(c_bnd);
-                    //celix::impl::BundleImpl bnd{m_bnd};
-                    (entry->set)(svc);
-                };
-                const char *cname = serviceName.empty() ? nullptr : serviceName.c_str();
-
-                opts.filter.serviceName = cname;
-                opts.filter.serviceLanguage = CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE;
-
-                auto te = std::unique_ptr<TrackEntry>{new TrackEntry{}};
-                te->set = std::move(set);
-
-                opts.callbackHandle = te.get();
-                opts.set = c_set;
-
-                long id = celix_bundleContext_trackServicesWithOptions(this->c_ctx, &opts);
-                if (id >= 0) {
+            long registerServiceInternal(celix::ServiceRegistrationEntry&& entry)
noexcept  override {
+                long svcId = celix_bundleContext_registerServiceWithOptions(this->c_ctx,
&entry.cOpts);
+                if (svcId >= 0) {
                     std::lock_guard<std::mutex> lock{this->mutex};
-                    this->trackEntries[id] = std::move(te);
+                    this->registrationEntries[svcId] = std::move(entry);
                 }
-                return id;
+                return svcId;
             }
 
-            long trackServicesInternal(
-                    const std::string &serviceName,
-                    std::function<void(void *svc)> add,
-                    std::function<void(void *svc)> remove
-            ) noexcept override {
-                celix_service_tracking_options_t opts;
-                std::memset(&opts, 0, sizeof(opts));
-
-                auto c_add = [](void *handle, void *svc) {
-                    auto *entry = static_cast<TrackEntry*>(handle);
-                    //celix::Properties props = createFromCProps(c_props);
-                    //auto m_bnd = const_cast<celix_bundle_t *>(c_bnd);
-                    //celix::impl::BundleImpl bnd{m_bnd};
-                    (entry->add)(svc);
-                };
-                auto c_remove = [](void *handle, void *svc) {
-                    auto *entry = static_cast<TrackEntry*>(handle);
-                    //celix::Properties props = createFromCProps(c_props);
-                    //auto m_bnd = const_cast<celix_bundle_t *>(c_bnd);
-                    //celix::impl::BundleImpl bnd{m_bnd};
-                    (entry->remove)(svc);
-                };
-
-                opts.filter.serviceName = serviceName.empty() ? nullptr : serviceName.c_str();
-                opts.filter.serviceLanguage = CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE;
-
-                auto te = std::unique_ptr<TrackEntry>{new TrackEntry{}};
-                te->add = std::move(add);
-                te->remove = std::move(remove);
-
-                opts.callbackHandle = te.get();
-                opts.add = c_add;
-                opts.remove = c_remove;
-
-                long id = celix_bundleContext_trackServicesWithOptions(this->c_ctx, &opts);
-                if (id >= 0) {
+            long trackServicesInternal(celix::ServiceTrackingEntry &&entry) noexcept
override {
+                long trkId = celix_bundleContext_trackServicesWithOptions(this->c_ctx,
&entry.cOpts);
+                if (trkId >= 0) {
                     std::lock_guard<std::mutex> lock{this->mutex};
-                    this->trackEntries[id] = std::move(te);
+                    this->trackingEntries[trkId] = std::move(entry);
                 }
-                return id;
+                return trkId;
             }
 
             bool useServiceInternal(
@@ -293,22 +272,9 @@ namespace celix {
             celix::impl::BundleImpl bnd;
             celix::dm::DependencyManager dm;
 
-            struct TrackEntry {
-                std::function<void(void *)> set{};
-                std::function<void(void *, const celix::Properties &)> setWithProperties{};
-                std::function<void(void *, const celix::Properties &, const celix::Bundle
&)> setWithOwner{};
-
-                std::function<void(void *)> add{};
-                std::function<void(void *, const celix::Properties &)> addWithProperties{};
-                std::function<void(void *, const celix::Properties &, const celix::Bundle
&)> addWithOwner{};
-
-                std::function<void(void *)> remove{};
-                std::function<void(void *, const celix::Properties &)> removeWithProperties{};
-                std::function<void(void *, const celix::Properties &, const celix::Bundle
&)> removeWithOwner{};
-            };
-
             std::mutex mutex{};
-            std::map<long,std::unique_ptr<TrackEntry>> trackEntries{};
+            std::map<long,ServiceTrackingEntry> trackingEntries{};
+            std::map<long,celix::ServiceRegistrationEntry> registrationEntries{};
         };
     }
 }
@@ -331,43 +297,137 @@ long celix::BundleContext::registerCService(I *svc, const std::string
&serviceNa
 }
 
 template<typename I>
+long celix::BundleContext::registerServiceFactory(celix::IServiceFactory<I> *factory,
const std::string &serviceName, celix::Properties props) {
+    celix::ServiceRegistrationOptions<I> opts{factory, serviceName};
+    opts.properties = std::move(props);
+    return this->registerServiceWithOptions(opts);
+}
+
+template<typename I>
+long celix::BundleContext::registerCServiceFactory(IServiceFactory<I> *factory, const
std::string &serviceName, celix::Properties props) {
+    static_assert(std::is_pod<I>::value, "Service I must be a 'Plain Old Data' object");
+    celix::ServiceRegistrationOptions<I> opts{factory, serviceName};
+    opts.properties = std::move(props);
+    opts.serviceLanguage = celix::Constants::SERVICE_C_LANG;
+    return this->registerServiceWithOptions(opts);
+}
+
+template<typename I>
 long celix::BundleContext::registerServiceWithOptions(const celix::ServiceRegistrationOptions<I>&
opts) noexcept {
     celix_properties_t *c_props = celix_properties_create();
     for (auto &pair : opts.properties) {
         celix_properties_set(c_props, pair.first.c_str(), pair.second.c_str());
     }
 
-    celix_service_registration_options_t cOpts; //TODO compile error gcc = CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS;
-    std::memset(&cOpts, 0, sizeof(cOpts));
+    celix::ServiceRegistrationEntry re{};
+
+    re.cOpts = CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS;
+    if (opts.svc != nullptr) {
+        re.cOpts.svc = static_cast<void *>(opts.svc);
+    } else if (opts.factory != nullptr) {
+        auto c_getService = [](void *handle, const celix_bundle_t *requestingBundle, const
celix_properties_t *svcProperties) -> void* {
+            celix::IServiceFactory<I> *f = static_cast<celix::IServiceFactory<I>*>(handle);
+            auto mbnd = const_cast<celix_bundle_t*>(requestingBundle);
+            celix::impl::BundleImpl bundle{mbnd};
+            celix::Properties props = createFromCProps(svcProperties);
+            I *svc = f->getService(bundle, props);
+            return static_cast<void*>(svc);
+        };
+        auto c_ungetService = [](void *handle, const celix_bundle_t *requestingBundle, const
celix_properties_t *svcProperties) {
+            celix::IServiceFactory<I> *f = static_cast<celix::IServiceFactory<I>*>(handle);
+            auto mbnd = const_cast<celix_bundle_t*>(requestingBundle);
+            celix::impl::BundleImpl bundle{mbnd};
+            celix::Properties props = createFromCProps(svcProperties);
+            f->ungetService(bundle, props);
+        };
+        re.factory.handle = static_cast<void*>(opts.factory);
+        re.factory.getService = c_getService;
+        re.factory.ungetService = c_ungetService;
+        re.cOpts.factory = &re.factory;
+    }
+
+    re.cOpts.serviceName = opts.serviceName.c_str();
+    re.cOpts.serviceVersion = opts.serviceVersion.c_str();
+    re.cOpts.serviceLanguage = opts.serviceLanguage.c_str();
+    re.cOpts.properties = c_props;
 
-    cOpts.svc = static_cast<void*>(&opts.svc);
-    cOpts.serviceName = opts.serviceName.c_str();
-    cOpts.serviceVersion = opts.serviceVersion.c_str();
-    cOpts.serviceLanguage = opts.serviceLanguage.c_str();
-    cOpts.properties = c_props;
-    return this->registerServiceInternal(cOpts);
+    return this->registerServiceInternal(std::move(re));
 }
 
 template<typename I>
 long celix::BundleContext::trackService(const std::string &serviceName, std::function<void(I
*svc)> set) noexcept {
-    return this->trackServiceInternal(serviceName, [set](void *voidSvc) {
-        I* typedSvc = static_cast<I*>(voidSvc);
-        set(typedSvc);
-    });
+    celix::ServiceTrackingOptions<I> opts{serviceName};
+    opts.set = std::move(set);
+    return this->trackServicesWithOptions<I>(opts);
 }
 
 template<typename I>
 long celix::BundleContext::trackServices(const std::string &serviceName,
         std::function<void(I *svc)> add, std::function<void(I *svc)> remove)
noexcept {
-    auto voidAdd = [add](void *voidSvc) {
-        I *typedSvc = static_cast<I *>(voidSvc);
-        add(typedSvc);
-    };
-    auto voidRemove = [remove](void *voidSvc) {
-        I *typedSvc = static_cast<I *>(voidSvc);
-        remove(typedSvc);
-    };
-    return this->trackServicesInternal(serviceName, std::move(voidAdd), std::move(voidRemove));
+    celix::ServiceTrackingOptions<I> opts{serviceName};
+    opts.add = std::move(add);
+    opts.remove = std::move(remove);
+    return this->trackServicesWithOptions<I>(opts);
+}
+
+template<typename I>
+long celix::BundleContext::trackServicesWithOptions(const celix::ServiceTrackingOptions<I>&
opts) {
+    celix::ServiceTrackingEntry entry{};
+    entry.functions = std::unique_ptr<ServiceTrackingEntryFunctions>{new ServiceTrackingEntryFunctions()};
+
+    auto set = opts.set;
+    if (set) {
+        auto voidSet = [set](void *voidSvc) {
+            I *typedSvc = static_cast<I*>(voidSvc);
+            set(typedSvc);
+        };
+        entry.cOpts.set = [](void *handle, void *svc) {
+            auto *fentry = static_cast<ServiceTrackingEntryFunctions*>(handle);
+            (fentry->set)(svc);
+        };
+    }
+
+    auto setWithProperties = opts.setWithProperties;
+    if (setWithProperties) {
+        auto voidSet = [setWithProperties](void *voidSvc, const celix::Properties &props)
{
+            I *typedSvc = static_cast<I*>(voidSvc);
+            setWithProperties(typedSvc, props);
+        };
+        entry.cOpts.setWithProperties = [](void *handle, void *svc, const celix_properties_t
*c_props) {
+            auto *fentry = static_cast<ServiceTrackingEntryFunctions*>(handle);
+            celix::Properties props = createFromCProps(c_props);
+            (fentry->setWithProperties)(svc, props);
+        };
+    }
+
+    auto setWithOwner = opts.setWithOwner;
+    if (setWithOwner) {
+        auto voidSet = [setWithOwner](void *voidSvc, const celix::Properties &props,
const celix::Bundle &bnd) {
+            I *typedSvc = static_cast<I*>(voidSvc);
+            setWithOwner(typedSvc, props, bnd);
+        };
+        entry.cOpts.setWithOwner = [](void *handle, void *svc, const celix_properties_t *c_props,
const celix_bundle_t *c_bnd) {
+            auto *fentry = static_cast<ServiceTrackingEntryFunctions*>(handle);
+            celix::Properties props = createFromCProps(c_props);
+            auto m_bnd = const_cast<celix_bundle_t *>(c_bnd);
+            celix::impl::BundleImpl bnd{m_bnd};
+            (fentry->setWithOwner)(svc, props, bnd);
+        };
+    }
+
+
+    //TODO add
+    //TODO remove
+
+
+    entry.cOpts.filter.serviceName = opts.filter.serviceName.c_str();
+    entry.cOpts.filter.serviceLanguage = opts.filter.serviceLanguage.c_str();
+    entry.cOpts.filter.versionRange = opts.filter.versionRange.c_str();
+    entry.cOpts.filter.filter = opts.filter.filter.c_str();
+
+    entry.cOpts.callbackHandle = entry.functions.get();
+
+    return this->trackServicesInternal(std::move(entry));
 }
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/ad2ee8ed/framework/include/celix/impl/BundleImpl.h
----------------------------------------------------------------------
diff --git a/framework/include/celix/impl/BundleImpl.h b/framework/include/celix/impl/BundleImpl.h
index 5fc6374..e56a5b7 100644
--- a/framework/include/celix/impl/BundleImpl.h
+++ b/framework/include/celix/impl/BundleImpl.h
@@ -30,11 +30,11 @@ namespace celix {
     namespace impl {
         class BundleImpl : public celix::Bundle {
         public:
-            BundleImpl(celix_bundle_context_t *c_ctx) : c_bnd{nullptr} {
+            BundleImpl(celix_bundle_context_t *c_ctx) : c_bnd(nullptr) {
                 bundleContext_getBundle(c_ctx, &this->c_bnd);
             }
 
-            BundleImpl(celix_bundle_t *b) : c_bnd{b} {
+            BundleImpl(celix_bundle_t *b) : c_bnd(b) {
             }
 
             virtual ~BundleImpl() {

http://git-wip-us.apache.org/repos/asf/celix/blob/ad2ee8ed/framework/include/celix/impl/FrameworkImpl.h
----------------------------------------------------------------------
diff --git a/framework/include/celix/impl/FrameworkImpl.h b/framework/include/celix/impl/FrameworkImpl.h
index 7043ffa..175a459 100644
--- a/framework/include/celix/impl/FrameworkImpl.h
+++ b/framework/include/celix/impl/FrameworkImpl.h
@@ -32,12 +32,12 @@ namespace celix {
 
         class FrameworkImpl : public celix::Framework {
         public:
-            FrameworkImpl(celix_bundle_context_t *c_ctx) : owner{false} {
+            FrameworkImpl(celix_bundle_context_t *c_ctx) : owner(false) {
                 bundleContext_getFramework(c_ctx, &this->c_fwm);
                 this->setFrameworkContext();
             }
 
-            FrameworkImpl(framework_t *c_fw) : owner{false} {
+            FrameworkImpl(framework_t *c_fw) : owner(false) {
                 //wrapper framework
                 this->c_fwm = c_fw;
                 //assume started framework
@@ -49,7 +49,7 @@ namespace celix {
             FrameworkImpl(FrameworkImpl&&) = delete;
             FrameworkImpl& operator=(FrameworkImpl&&) = delete;
 
-            FrameworkImpl(celix::Properties config) : owner{true} {
+            FrameworkImpl(celix::Properties config) : owner(true) {
                 //framework which also owns the underlining c framework
                 auto c_config = properties_create();
                 for (auto &pair : config) {


Mime
View raw message