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-269: Refactoring of calculateNewState function
Date Thu, 05 Nov 2015 15:12:40 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 736af0e44 -> f119c346e


CELIX-269: Refactoring of calculateNewState function


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

Branch: refs/heads/develop
Commit: f119c346e5f41e7eb6a9660ce48aa1aa83a22db8
Parents: 736af0e
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Thu Nov 5 16:11:39 2015 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Thu Nov 5 16:11:39 2015 +0100

----------------------------------------------------------------------
 .../private/src/dm_component_impl.c             | 71 ++++++++++----------
 1 file changed, 34 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/f119c346/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 127d984..d08bc28 100644
--- a/dependency_manager/private/src/dm_component_impl.c
+++ b/dependency_manager/private/src/dm_component_impl.c
@@ -680,62 +680,59 @@ celix_status_t component_calculateNewState(dm_component_pt component,
dm_compone
     if (currentState == DM_CMP_STATE_INACTIVE) {
         if (component->isStarted) {
             *newState = DM_CMP_STATE_WAITING_FOR_REQUIRED;
-            return status;
+        } else {
+            *newState = currentState;
         }
-    }
-    if (currentState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
+    } else if (currentState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
         if (!component->isStarted) {
             *newState = DM_CMP_STATE_INACTIVE;
-            return status;
-        }
-
-        bool available = false;
-        component_allRequiredAvailable(component, &available);
+        } else {
+            bool available = false;
+            component_allRequiredAvailable(component, &available);
 
-        if (available) {
-            *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
-            return status;
+            if (available) {
+                *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
+            } else {
+                *newState = currentState;
+            }
         }
-    }
-    if (currentState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
-        bool available = false;
-        component_allRequiredAvailable(component, &available);
+    } else if (currentState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
+        if (!component->isStarted) {
+            *newState = DM_CMP_STATE_WAITING_FOR_REQUIRED;
+        } else {
+            bool available = false;
+            component_allRequiredAvailable(component, &available);
 
-        if (component->isStarted && available) {
-            bool instanceBoundAvailable = false;
-            component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
+            if (available) {
+                bool instanceBoundAvailable = false;
+                component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
 
-            if (instanceBoundAvailable) {
-                *newState = DM_CMP_STATE_TRACKING_OPTIONAL;
-                return status;
+                if (instanceBoundAvailable) {
+                    *newState = DM_CMP_STATE_TRACKING_OPTIONAL;
+                } else {
+                    *newState = currentState;
+                }
+            } else {
+                *newState = currentState;
             }
-
-            *newState = currentState;
-            return status;
         }
-
-        *newState = component->isStarted ? DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED
:
-                        DM_CMP_STATE_WAITING_FOR_REQUIRED;
-        return status;
-    }
-    if (currentState == DM_CMP_STATE_TRACKING_OPTIONAL) {
+    } else if (currentState == DM_CMP_STATE_TRACKING_OPTIONAL) {
         bool instanceBoundAvailable = false;
         bool available = false;
 
         component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
         component_allRequiredAvailable(component, &available);
 
-        if (component->isStarted  && available && instanceBoundAvailable)
{
+        if (component->isStarted && available && instanceBoundAvailable)
{
             *newState = currentState;
-            return status;
+        } else {
+            *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
         }
-
-        *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
-        return status;
+    } else {
+        //should not reach
+        status = CELIX_BUNDLE_EXCEPTION;
     }
 
-    *newState = currentState;
-
     return status;
 }
 


Mime
View raw message