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-386: Refactor registering callbacks for C++ dep man. callbacks are now always converted to std::function.
Date Tue, 21 Mar 2017 20:02:14 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 4b760987a -> 544906ff6


CELIX-386: Refactor registering callbacks for C++ dep man. callbacks are now always converted
to std::function.


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

Branch: refs/heads/develop
Commit: 544906ff6f8e2a6d6fe8dc29fb615cfa54904e70
Parents: 4b76098
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Tue Mar 21 21:01:14 2017 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Tue Mar 21 21:01:14 2017 +0100

----------------------------------------------------------------------
 .../private/src/dm_component_impl.c             |   2 +-
 .../public/include/dm_component.h               |   4 +-
 .../public/include/dm_service_dependency.h      |   2 +-
 .../include/celix/dm/Component_Impl.h           |   4 +-
 .../include/celix/dm/ServiceDependency.h        |  67 ++++--
 .../include/celix/dm/ServiceDependency_Impl.h   | 229 +++++++++----------
 6 files changed, 165 insertions(+), 143 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/544906ff/dependency_manager/private/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_component_impl.c b/dependency_manager/private/src/dm_component_impl.c
index 27db3a5..13a2ee0 100644
--- a/dependency_manager/private/src/dm_component_impl.c
+++ b/dependency_manager/private/src/dm_component_impl.c
@@ -330,7 +330,7 @@ celix_status_t component_stopTask(dm_component_pt component, void *data
__attrib
     return status;
 }
 
-celix_status_t setCLanguageProperty(dm_component_pt component, bool setCLangProp) {
+celix_status_t component_setCLanguageProperty(dm_component_pt component, bool setCLangProp)
{
     component->setCLanguageProperty = setCLangProp;
     return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/544906ff/dependency_manager/public/include/dm_component.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_component.h b/dependency_manager/public/include/dm_component.h
index f88171c..2cdad6d 100644
--- a/dependency_manager/public/include/dm_component.h
+++ b/dependency_manager/public/include/dm_component.h
@@ -68,9 +68,9 @@ void component_destroy(dm_component_pt component);
 
 /**
  * Specify if a default 'service.lang=C' should be added to the properties of interfaces
if no 'service.lang' has been
- * provided. Default is true. Note that this should be set before using component_addInterface.
+ * provided. Default is false. Note that this should be set before using component_addInterface.
  */
-celix_status_t setCLanguageProperty(dm_component_pt component, bool setCLangProp);
+celix_status_t component_setCLanguageProperty(dm_component_pt component, bool setCLangProp);
 
 
 /**

http://git-wip-us.apache.org/repos/asf/celix/blob/544906ff/dependency_manager/public/include/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_service_dependency.h b/dependency_manager/public/include/dm_service_dependency.h
index ba63d0a..fb34230 100644
--- a/dependency_manager/public/include/dm_service_dependency.h
+++ b/dependency_manager/public/include/dm_service_dependency.h
@@ -74,7 +74,7 @@ celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency
 
 /**
  * Specify if the servide dependency should add a C language filter for this dependency if
no "service.lang" part if found the in the provided filter.
- * Default is true
+ * Default is false
  */
 celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt dependency,
bool addCLangFilter);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/544906ff/dependency_manager_cxx/include/celix/dm/Component_Impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/Component_Impl.h b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
index 86dbe33..81b3903 100644
--- a/dependency_manager_cxx/include/celix/dm/Component_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
@@ -93,7 +93,7 @@ template<class T>
 template<class I>
 ServiceDependency<T,I>& Component<T>::createServiceDependency(const std::string
name) {
 #ifdef __EXCEPTIONS
-    auto dep = std::shared_ptr<ServiceDependency<T,I>> {new ServiceDependency<T,I>()};
+    auto dep = std::shared_ptr<ServiceDependency<T,I>> {new ServiceDependency<T,I>(name)};
 #else
     static ServiceDependency<T,I> invalidDep{std::string{}, false};
     auto dep = std::shared_ptr<ServiceDependency<T,I>> {new(std::nothrow) ServiceDependency<T,I>(name)};
@@ -119,7 +119,7 @@ template<class T>
 template<typename I>
 CServiceDependency<T,I>& Component<T>::createCServiceDependency(const std::string
name) {
 #ifdef __EXCEPTIONS
-    auto dep = std::shared_ptr<CServiceDependency<T,I>> {new CServiceDependency<T,I>()};
+    auto dep = std::shared_ptr<CServiceDependency<T,I>> {new CServiceDependency<T,I>(name)};
 #else
     static CServiceDependency<T,I> invalidDep{std::string{}, false};
     auto dep = std::shared_ptr<CServiceDependency<T,I>> {new(std::nothrow) CServiceDependency<T,I>(name)};

http://git-wip-us.apache.org/repos/asf/celix/blob/544906ff/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
index c664fb2..55be966 100644
--- a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
@@ -29,6 +29,7 @@
 #include <tuple>
 #include <memory>
 #include <iostream>
+#include <functional>
 
 /**
  * TODO add a dependency for a whiteboard pattern or marker service. e.g. a service where
the type is irrelevant.
@@ -88,18 +89,12 @@ namespace celix { namespace dm {
         std::string filter {};
         std::string versionRange {};
 
-        void (T::*setFp)(const I* service) {nullptr};
-        void (T::*setFpWithProperties)(const I* service, Properties&& properties)
{nullptr};
-
-        void (T::*addFp)(const I* service) {nullptr};
-        void (T::*addFpWithProperties)(const I* service, Properties&& properties)
{nullptr};
-
-        void (T::*removeFp)(const I* service) {nullptr};
-        void (T::*removeFpWithProperties)(const I* service, Properties&& properties)
{nullptr};
+	std::function<void(const I* service, Properties&& properties)> setFp{nullptr};
+	std::function<void(const I* service, Properties&& properties)> addFp{nullptr};
+	std::function<void(const I* service, Properties&& properties)> removeFp{nullptr};
 
         void setupCallbacks();
-        int invokeCallback(void(T::*fp)(const I*), const void* service);
-        int invokeCallbackWithProperties(void(T::*fp)(const I*, Properties&&), service_reference_pt
 ref, const void* service);
+        int invokeCallback(std::function<void(const I*, Properties&&)> fp,
service_reference_pt  ref, const void* service);
 
         void setupService();
     public:
@@ -151,11 +146,18 @@ namespace celix { namespace dm {
         CServiceDependency<T,I>& setCallbacks(void (T::*set)(const I* service,
Properties&& properties));
 
         /**
+         * Set the set callback for when the service dependency becomes available
+         *
+         * @return the C service dependency reference for chaining (fluent API)
+         */
+        CServiceDependency<T,I>& setCallbacks(std::function<void(const I* service,
Properties&& properties)> set);
+
+        /**
          * Set the add and remove callback for when the services of service dependency are
added or removed.
          *
          * @return the C service dependency reference for chaining (fluent API)
          */
-        CServiceDependency<T,I>& setCallbacks( void (T::*add)(const I* service),
 void (T::*remove)(const I* service));
+        CServiceDependency<T,I>& setCallbacks(void (T::*add)(const I* service),
 void (T::*remove)(const I* service));
 
         /**
          * Set the add and remove callback for when the services of service dependency are
added or removed.
@@ -168,6 +170,16 @@ namespace celix { namespace dm {
         );
 
         /**
+         * Set the add and remove callback for when the services of service dependency are
added or removed.
+         *
+         * @return the C service dependency reference for chaining (fluent API)
+         */
+        CServiceDependency<T,I>& setCallbacks(
+		std::function<void(const I* service, Properties&& properties)> add,
+		std::function<void(const I* service, Properties&& properties)> remove
+        );
+
+        /**
          * Specify if the service dependency should add a service.lang filter part if it
is not already present
          * For C service dependencies 'service.lang=C' will be added.
          */
@@ -184,19 +196,13 @@ namespace celix { namespace dm {
         std::string versionRange {};
         std::string modifiedFilter {};
 
-        void (T::*setFp)(I* service) {nullptr};
-        void (T::*setFpWithProperties)(I* service, Properties&& properties) {nullptr};
-
-        void (T::*addFp)(I* service) {nullptr};
-        void (T::*addFpWithProperties)(I* service, Properties&& properties) {nullptr};
-
-        void (T::*removeFp)(I* service) {nullptr};
-        void (T::*removeFpWithProperties)(I* service, Properties&& properties) {nullptr};
+	std::function<void(I* service, Properties&& properties)> setFp{nullptr};
+	std::function<void(I* service, Properties&& properties)> addFp{nullptr};
+	std::function<void(I* service, Properties&& properties)> removeFp{nullptr};
 
         void setupService();
         void setupCallbacks();
-        int invokeCallback(void(T::*fp)(I*), const void* service);
-        int invokeCallbackWithProperties(void(T::*fp)(I*, Properties&&), service_reference_pt
 ref, const void* service);
+        int invokeCallback(std::function<void(I*, Properties&&)> fp, service_reference_pt
 ref, const void* service);
     public:
         ServiceDependency(const std::string name = std::string{}, bool valid = true);
         virtual ~ServiceDependency() = default;
@@ -237,11 +243,18 @@ namespace celix { namespace dm {
         ServiceDependency<T,I>& setCallbacks(void (T::*set)(I* service, Properties&&
properties));
 
         /**
+         * Set the set callback for when the service dependency becomes available
+         *
+         * @return the C service dependency reference for chaining (fluent API)
+         */
+        ServiceDependency<T,I>& setCallbacks(std::function<void(I* service,
Properties&& properties)> set);
+
+        /**
          * Set the add and remove callback for when the services of service dependency are
added or removed.
          *
          * @return the C++ service dependency reference for chaining (fluent API)
          */
-        ServiceDependency<T,I>& setCallbacks( void (T::*add)(I* service),  void
(T::*remove)(I* service));
+        ServiceDependency<T,I>& setCallbacks(void (T::*add)(I* service),  void
(T::*remove)(I* service));
 
         /**
          * Set the add and remove callback for when the services of service dependency are
added or removed.
@@ -254,6 +267,16 @@ namespace celix { namespace dm {
         );
 
         /**
+         * Set the add and remove callback for when the services of service dependency are
added or removed.
+         *
+         * @return the C service dependency reference for chaining (fluent API)
+         */
+        ServiceDependency<T,I>& setCallbacks(
+		std::function<void(I* service, Properties&& properties)> add,
+		std::function<void(I* service, Properties&& properties)> remove
+        );
+
+        /**
          * Specify if the service dependency is required. Default is false
          *
          * @return the C service dependency reference for chaining (fluent API)

http://git-wip-us.apache.org/repos/asf/celix/blob/544906ff/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
index f22c0c5..731800d 100644
--- a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
@@ -55,9 +55,9 @@ void CServiceDependency<T,I>::setupService() {
 
 template<class T, typename I>
 CServiceDependency<T,I>& CServiceDependency<T,I>::setAddLanguageFilter(bool
addLang) {
-    if (!this->valid) {
-        *this;
-    }
+//    if (!this->valid) {
+//        *this;
+//    }
     serviceDependency_setAddCLanguageFilter(this->cServiceDependency(), addLang);
     this->setupService();
     return *this;
@@ -84,14 +84,25 @@ CServiceDependency<T,I>& CServiceDependency<T,I>::setStrategy(DependencyUpdateSt
 //set callbacks
 template<class T, typename I>
 CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(void (T::*set)(const
I* service)) {
-    this->setFp = set;
-    this->setupCallbacks();
+    this->setCallbacks([this, set](const I* service, Properties&& properties)
{
+        T *cmp = this->componentInstance;
+        (cmp->*set)(service);
+    });
     return *this;
 }
 
 template<class T, typename I>
 CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(void (T::*set)(const
I* service, Properties&& properties)) {
-    this->setFpWithProperties = set;
+    this->setCallbacks([this, set](const I* service, Properties&& properties)
{
+        T *cmp = this->componentInstance;
+        (cmp->*set)(service, std::move(properties));
+    });
+    return *this;
+}
+
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(std::function<void(const
I* service, Properties&& properties)> set) {
+    this->setFp = set;
     this->setupCallbacks();
     return *this;
 }
@@ -101,9 +112,16 @@ template<class T, typename I>
 CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(
         void (T::*add)(const I* service),
         void (T::*remove)(const I* service)) {
-    this->addFp = add;
-    this->removeFp = remove;
-    this->setupCallbacks();
+    this->setCallbacks(
+		    [this, add](const I* service, Properties&& properties) {
+			    T *cmp = this->componentInstance;
+			    (cmp->*add)(service);
+		    },
+		    [this, remove](const I* service, Properties&& properties) {
+			    T *cmp = this->componentInstance;
+			    (cmp->*remove)(service);
+		    }
+    );
     return *this;
 }
 
@@ -112,8 +130,23 @@ CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(
         void (T::*add)(const I* service, Properties&& properties),
         void (T::*remove)(const I* service, Properties&& properties)
 ) {
-    this->addFpWithProperties = add;
-    this->removeFpWithProperties = remove;
+    this->setCallbacks(
+		    [this, add](const I* service, Properties&& properties) {
+			    T *cmp = this->componentInstance;
+			    (cmp->*add)(service, std::move(properties));
+		    },
+		    [this, remove](const I* service, Properties&& properties) {
+			    T *cmp = this->componentInstance;
+			    (cmp->*remove)(service, std::move(properties));
+		    }
+    );
+    return *this;
+}
+
+template<class T, typename I>
+CServiceDependency<T,I>& CServiceDependency<T,I>::setCallbacks(std::function<void(const
I* service, Properties&& properties)> add, std::function<void(const I* service,
Properties&& properties)> remove) {
+    this->addFp = add;;
+    this->removeFp = remove;
     this->setupCallbacks();
     return *this;
 }
@@ -125,71 +158,36 @@ void CServiceDependency<T,I>::setupCallbacks() {
         return;
     }
 
-    int(*cset)(void*,const void*) {nullptr};
-    int(*cadd)(void*, const void*) {nullptr};
-    int(*cremove)(void*, const void*) {nullptr};
-
+    int(*cset)(void*, service_reference_pt, const void*) {nullptr};
+    int(*cadd)(void*, service_reference_pt, const void*) {nullptr};
+    int(*crem)(void*, service_reference_pt, const void*) {nullptr};
 
     if (setFp != nullptr) {
-        cset = [](void* handle, const void* service) -> int {
+        cset = [](void* handle, service_reference_pt ref, const void* service) -> int
{
             auto dep = (CServiceDependency<T,I>*) handle;
-            return dep->invokeCallback(dep->setFp, service);
+            return dep->invokeCallback(dep->setFp, ref, service);
         };
     }
     if (addFp != nullptr) {
-        cadd = [](void* handle, const void* service) -> int {
+        cadd = [](void* handle, service_reference_pt ref, const void* service) -> int
{
             auto dep = (CServiceDependency<T,I>*) handle;
-            return dep->invokeCallback(dep->addFp, service);
+            return dep->invokeCallback(dep->addFp, ref, service);
         };
     }
     if (removeFp != nullptr) {
-        cremove = [](void* handle, const void* service) -> int {
+        crem= [](void* handle, service_reference_pt ref, const void* service) -> int {
             auto dep = (CServiceDependency<T,I>*) handle;
-            return dep->invokeCallback(dep->removeFp, service);
+            return dep->invokeCallback(dep->removeFp, ref, service);
         };
     }
-
-    int(*csetWithRef)(void*, service_reference_pt, const void*) {nullptr};
-    int(*caddWithRef)(void*, service_reference_pt, const void*) {nullptr};
-    int(*cremoveWithRef)(void*, service_reference_pt, const void*) {nullptr};
-
-    if (setFpWithProperties != nullptr) {
-        csetWithRef = [](void* handle, service_reference_pt ref, const void* service) ->
int {
-            auto dep = (CServiceDependency<T,I>*) handle;
-            return dep->invokeCallbackWithProperties(dep->setFpWithProperties, ref,
service);
-        };
-    }
-    if (addFpWithProperties != nullptr) {
-        caddWithRef = [](void* handle, service_reference_pt ref, const void* service) ->
int {
-            auto dep = (CServiceDependency<T,I>*) handle;
-            return dep->invokeCallbackWithProperties(dep->addFpWithProperties, ref,
service);
-        };
-    }
-    if (removeFpWithProperties != nullptr) {
-        cremoveWithRef = [](void* handle, service_reference_pt ref, const void* service)
-> int {
-            auto dep = (CServiceDependency<T,I>*) handle;
-            return dep->invokeCallbackWithProperties(dep->removeFpWithProperties, ref,
service);
-        };
-    }
-
     serviceDependency_setCallbackHandle(this->cServiceDependency(), this);
-    serviceDependency_setCallbacks(this->cServiceDependency(), cset, cadd, nullptr, cremove,
nullptr);
-    serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), csetWithRef,
caddWithRef, nullptr, cremoveWithRef, nullptr);
-};
-
-template<class T, typename I>
-int CServiceDependency<T,I>::invokeCallback(void(T::*fp)(const I*), const void* service)
{
-    T *cmp = this->componentInstance;
-    const I* srv = (const I*) service;
-    (cmp->*fp)(srv);
-    return 0;
-};
+    serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), cset,
cadd, nullptr, crem, nullptr);
+}
 
 template<class T, typename I>
-int CServiceDependency<T,I>::invokeCallbackWithProperties(void(T::*fp)(const I*, Properties&&),
service_reference_pt  ref, const void* service) {
+int CServiceDependency<T,I>::invokeCallback(std::function<void(const I*, Properties&&)>
fp, service_reference_pt  ref, const void* service) {
     service_registration_pt reg {nullptr};
     properties_pt props {nullptr};
-    T *cmp = this->componentInstance;
     serviceReference_getServiceRegistration(ref, &reg);
     serviceRegistration_getProperties(reg, &props);
 
@@ -207,7 +205,7 @@ int CServiceDependency<T,I>::invokeCallbackWithProperties(void(T::*fp)(const
I*,
 
     const I* srv = (const I*) service;
 
-    (cmp->*fp)(srv, static_cast<Properties&&>(properties)); //explicit move
of lvalue properties.
+    fp(srv, std::move(properties));
     return 0;
 }
 
@@ -305,14 +303,25 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setAddLanguageFilter(bool
addLan
 //set callbacks
 template<class T, class I>
 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(I*
service)) {
-    this->setFp = set;
-    this->setupCallbacks();
+    this->setCallbacks([this, set](I* srv, Properties&& props) {
+        T *cmp = this->componentInstance;
+        (cmp->*set)(srv);
+    });
     return *this;
 }
 
 template<class T, class I>
 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(I*
service, Properties&& properties)) {
-    this->setFpWithProperties = set;
+    this->setCallbacks([this, set](I* srv, Properties&& props) {
+        T *cmp = this->componentInstance;
+        (cmp->*set)(srv, std::move(props));
+    });
+    return *this;
+}
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(std::function<void(I*
service, Properties&& properties)> set) {
+    this->setFp = set;
     this->setupCallbacks();
     return *this;
 }
@@ -322,9 +331,16 @@ template<class T, class I>
 ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(
         void (T::*add)(I* service),
         void (T::*remove)(I* service)) {
-    this->addFp = add;
-    this->removeFp = remove;
-    this->setupCallbacks();
+    this->setCallbacks(
+	    [this, add](I* srv, Properties&& props) {
+        	T *cmp = this->componentInstance;
+        	(cmp->*add)(srv);
+    	    },
+	    [this, remove](I* srv, Properties&& props) {
+        	T *cmp = this->componentInstance;
+        	(cmp->*remove)(srv);
+    	    }
+    );
     return *this;
 }
 
@@ -333,8 +349,25 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(
         void (T::*add)(I* service, Properties&& properties),
         void (T::*remove)(I* service, Properties&& properties)
         ) {
-    this->addFpWithProperties = add;
-    this->removeFpWithProperties = remove;
+    this->setCallbacks(
+	    [this, add](I* srv, Properties&& props) {
+        	T *cmp = this->componentInstance;
+        	(cmp->*add)(srv, std::move(props));
+    	    },
+	    [this, remove](I* srv, Properties&& props) {
+        	T *cmp = this->componentInstance;
+        	(cmp->*remove)(srv, std::move(props));
+    	    }
+    );
+    return *this;
+}
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(
+		std::function<void(I* service, Properties&& properties)> add,
+		std::function<void(I* service, Properties&& properties)> remove) {
+    this->addFp = add;
+    this->removeFp = remove;
     this->setupCallbacks();
     return *this;
 }
@@ -352,18 +385,9 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setStrategy(DependencyUpdateStra
 };
 
 template<class T, class I>
-int ServiceDependency<T,I>::invokeCallback(void(T::*fp)(I*), const void* service) {
-    T *cmp = this->componentInstance;
-    I *svc = (I*)service;
-    (cmp->*fp)(svc);
-    return 0;
-};
-
-template<class T, class I>
-int ServiceDependency<T,I>::invokeCallbackWithProperties(void(T::*fp)(I*, Properties&&),
service_reference_pt  ref, const void* service) {
+int ServiceDependency<T,I>::invokeCallback(std::function<void(I*, Properties&&)>
fp, service_reference_pt  ref, const void* service) {
     service_registration_pt reg {nullptr};
     properties_pt props {nullptr};
-    T *cmp = this->componentInstance;
     I *svc = (I*)service;
     serviceReference_getServiceRegistration(ref, &reg);
     serviceRegistration_getProperties(reg, &props);
@@ -380,7 +404,7 @@ int ServiceDependency<T,I>::invokeCallbackWithProperties(void(T::*fp)(I*,
Proper
         properties[key] = value;
     }
 
-    (cmp->*fp)(svc, static_cast<Properties&&>(properties)); //explicit move
of lvalue properties.
+    fp(svc, std::move(properties)); //explicit move of lvalue properties.
     return 0;
 }
 
@@ -390,54 +414,29 @@ void ServiceDependency<T,I>::setupCallbacks() {
         return;
     }
 
-    int(*cset)(void*,const void*) {nullptr};
-    int(*cadd)(void*, const void*) {nullptr};
-    int(*cremove)(void*, const void*) {nullptr};
-
+    int(*cset)(void*, service_reference_pt, const void*) {nullptr};
+    int(*cadd)(void*, service_reference_pt, const void*) {nullptr};
+    int(*crem)(void*, service_reference_pt, const void*) {nullptr};
 
     if (setFp != nullptr) {
-        cset = [](void* handle, const void*service) -> int {
-            auto dep = (ServiceDependency<T, I> *) handle;
-            return dep->invokeCallback(dep->setFp, service);
-        };
-    }
-    if (addFp != nullptr) {
-        cadd = [](void* handle, const void*service) -> int {
-            auto dep = (ServiceDependency<T, I> *) handle;
-            return dep->invokeCallback(dep->addFp, service);
-        };
-    }
-    if (removeFp != nullptr) {
-        cremove = [](void* handle, const void*service) -> int {
-            auto dep = (ServiceDependency<T, I> *) handle;
-            return dep->invokeCallback(dep->removeFp, service);
-        };
-    }
-
-    int(*csetWithRef)(void*, service_reference_pt, const void*) {nullptr};
-    int(*caddWithRef)(void*, service_reference_pt, const void*) {nullptr};
-    int(*cremoveWithRef)(void*, service_reference_pt, const void*) {nullptr};
-
-    if (setFpWithProperties != nullptr) {
-        csetWithRef = [](void* handle, service_reference_pt ref, const void* service) ->
int {
+        cset = [](void* handle, service_reference_pt ref, const void* service) -> int
{
             auto dep = (ServiceDependency<T,I>*) handle;
-            return dep->invokeCallbackWithProperties(dep->setFpWithProperties, ref,
service);
+            return dep->invokeCallback(dep->setFp, ref, service);
         };
     }
-    if (addFpWithProperties != nullptr) {
-        caddWithRef = [](void* handle, service_reference_pt ref, const void* service) ->
int {
+    if (addFp != nullptr) {
+        cadd = [](void* handle, service_reference_pt ref, const void* service) -> int
{
             auto dep = (ServiceDependency<T,I>*) handle;
-            return dep->invokeCallbackWithProperties(dep->addFpWithProperties, ref,
service);
+            return dep->invokeCallback(dep->addFp, ref, service);
         };
     }
-    if (removeFpWithProperties != nullptr) {
-        cremoveWithRef = [](void* handle, service_reference_pt ref, const void* service)
-> int {
+    if (removeFp != nullptr) {
+        crem = [](void* handle, service_reference_pt ref, const void* service) -> int
{
             auto dep = (ServiceDependency<T,I>*) handle;
-            return dep->invokeCallbackWithProperties(dep->removeFpWithProperties, ref,
service);
+            return dep->invokeCallback(dep->removeFp, ref, service);
         };
     }
 
     serviceDependency_setCallbackHandle(this->cServiceDependency(), this);
-    serviceDependency_setCallbacks(this->cServiceDependency(), cset, cadd, nullptr, cremove,
nullptr);
-    serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), csetWithRef,
caddWithRef, nullptr, cremoveWithRef, nullptr);
+    serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), cset,
cadd, nullptr, crem, nullptr);
 };


Mime
View raw message