celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erjanalt...@apache.org
Subject celix git commit: Added dependencyManager_remove(C) /DependencyManager::destroyComponent (C++) function to be able to remove a component from a started Dependency manager.
Date Thu, 19 Apr 2018 06:38:41 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 78460c7a7 -> 83cf4c964


Added dependencyManager_remove(C) /DependencyManager::destroyComponent (C++) function to be
able to remove a component from a started Dependency manager.


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

Branch: refs/heads/develop
Commit: 83cf4c9643005f4b7df8edc9b2498d2159608830
Parents: 78460c7
Author: Erjan Altena <erjanaltena@gmail.com>
Authored: Wed Apr 18 10:23:24 2018 +0200
Committer: Erjan Altena <erjanaltena@gmail.com>
Committed: Thu Apr 19 08:37:55 2018 +0200

----------------------------------------------------------------------
 dependency_manager/api/dm_dependency_manager.h        |  5 +++++
 dependency_manager/src/dm_dependency_manager_impl.c   | 14 ++++++++++++--
 .../include/celix/dm/DependencyManager.h              |  8 ++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/83cf4c96/dependency_manager/api/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_dependency_manager.h b/dependency_manager/api/dm_dependency_manager.h
index 89fe51d..8e01302 100644
--- a/dependency_manager/api/dm_dependency_manager.h
+++ b/dependency_manager/api/dm_dependency_manager.h
@@ -57,6 +57,11 @@ void dependencyManager_destroy(dm_dependency_manager_pt manager);
 celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component);
 
 /**
+ * Removes a DM component from the dependency manager and destroys it
+ */
+celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager, dm_component_pt
component);
+
+/**
  * Removes all DM components from the dependency manager
  */
 celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager);

http://git-wip-us.apache.org/repos/asf/celix/blob/83cf4c96/dependency_manager/src/dm_dependency_manager_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_dependency_manager_impl.c b/dependency_manager/src/dm_dependency_manager_impl.c
index 4864be1..14c02f6 100644
--- a/dependency_manager/src/dm_dependency_manager_impl.c
+++ b/dependency_manager/src/dm_dependency_manager_impl.c
@@ -66,6 +66,16 @@ celix_status_t dependencyManager_add(dm_dependency_manager_pt manager,
dm_compon
 	return status;
 }
 
+celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager, dm_component_pt
component) {
+    celix_status_t status;
+
+	arrayList_removeElement(manager->components, component);
+    status = component_stop(component);
+    component_destroy(component);
+
+    return status;
+}
+
 celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager) {
 	celix_status_t status = CELIX_SUCCESS;
 
@@ -89,7 +99,7 @@ celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt
ma
 
 celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt
*out) {
 	celix_status_t status = CELIX_SUCCESS;
-	int i;
+	unsigned int i;
 	int size;
 	dm_component_info_pt cmpInfo = NULL;
 	dm_dependency_manager_info_pt info = calloc(1, sizeof(*info));
@@ -118,7 +128,7 @@ celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager,
dm_de
 	return status;
 }
 
-void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt
info) {
+void dependencyManager_destroyInfo(dm_dependency_manager_pt __attribute__((__unused__)) manager,
dm_dependency_manager_info_pt info) {
     unsigned int i = 0;
     for (; i < arrayList_size(info->components); i += 1) {
         dm_component_info_pt cmpinfo = (dm_component_info_pt)arrayList_get(info->components,
i);

http://git-wip-us.apache.org/repos/asf/celix/blob/83cf4c96/dependency_manager_cxx/include/celix/dm/DependencyManager.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager.h b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
index afafacc..8648bc9 100644
--- a/dependency_manager_cxx/include/celix/dm/DependencyManager.h
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
@@ -121,6 +121,14 @@ namespace celix { namespace dm {
         }
 
         /**
+         * Removes a component from the  Dependency Manager and destroys it
+         */
+        template<typename T>
+        void destroyComponent(Component<T> &component) {
+            dependencyManager_remove(cDepMan, component.cComponent());
+        }
+
+        /**
          * Stops the Dependency Manager
          */
         void stop() {


Mime
View raw message