]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkAtomicBlackBox.cxx
* Major changes on IOStatus update / propagation
[bbtk.git] / kernel / src / bbtkAtomicBlackBox.cxx
index 3ee7d62b05d0e98e685e87f7683b04fcbc9c382a..d42185163bdf9dd230273a65edeadd0bb414e272 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkAtomicBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/11/25 11:17:13 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2008/12/08 12:53:35 $
+  Version:   $Revision: 1.11 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -86,7 +86,7 @@ namespace bbtk
 
   //=========================================================================
   /// Main processing method of the box.
-  IOStatus AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
+  void AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
   {
     bbtkDebugMessageInc("process",3,
                        "=> AtomicBlackBox::bbBackwardUpdate("
@@ -97,64 +97,35 @@ namespace bbtk
     if (bbGetExecuting()) 
       {
        bbtkDebugMessage("process",3,
-                        " -> already executing : bailing out"<<std::endl);
-       return bbGetStatus();
+                        " -> already executing : returning"<<std::endl);
+       return
       }
+
     bbSetExecuting(true);
     bool wasExecuting = bbGlobalGetSomeBoxExecuting();
     bbGlobalSetSomeBoxExecuting(true);
 
-    bbtkDebugMessage("process",5,"Initial Status  = "<<bbGetStatus()
-                    <<std::endl);
-    bbtkDebugMessage("process",5,"BoxProcessMode  = "
-                    <<bbGetInputBoxProcessMode()<<std::endl);
-   
-
-    if ( ( bbGetStatus() == MODIFIED ) ||
-        ( bbBoxProcessModeIsAlways() ) )
-      {
-
-       //      bbSetStatus(UPDATING);
-
-        // Updates its inputs
-        IOStatus s = bbUpdateInputs();
+    // Updates its inputs
+    IOStatus s = bbUpdateInputs();
     
-        bbtkDebugMessage("process",6,"=> AtomicBlackBox::bbBackwardUpdate("
-                       <<(caller?caller->GetFullName():"0")<<") ["
-                       <<bbGetFullName()<<"] : Inputs post-update status = "<<s<<std::endl);
-        // If all inputs are in UPTODATE post-update status 
-        // and mProcessMode is not "Always"
-        // then the box is now UPTODATE
-       IOStatus new_status;
-        if ( ( s == UPTODATE ) && 
-            ( ! bbBoxProcessModeIsAlways() ) ) 
-            {
-                new_status = UPTODATE;
-            }
-        else 
-            {
-                // else it remains MODIFIED
-                 new_status = MODIFIED;
-            }
-       bbSetStatus(new_status);
-
-        // User process
-        bbProcess();
-
-        // Displays the window (WxBlackbox)
-        bbShowWindow(caller);
-
-
+    if ( (s != UPTODATE) ||
+        bbBoxProcessModeIsAlways() )
+      {
+       // User process
+       bbProcess();
+       
+       // Displays the window (WxBlackbox)
+       bbShowWindow(caller);
+       
+       // Update the I/O statuses
+       bbComputePostProcessStatus();
       }
     else 
       {
-        bbtkDebugMessage("process",5,"Up-to-date : nothing to do"<<std::endl);
+        bbtkDebugMessage("process",5," -> Up-to-date : nothing to do"
+                        <<std::endl);
       }
 
-    bbtkDebugMessage("process",5,"=> AtomicBlackBox::bbBackwardUpdate("
-                    <<(caller?caller->GetFullName():"0")<<") ["
-                    <<bbGetFullName()<<"] : Final Status    = "
-                    <<bbGetStatus()<<std::endl);
     bbtkDebugMessage("process",3,
             "<= AtomicBlackBox::bbBackwardUpdate() ["
             <<bbGetFullName()<<"]"<<std::endl);
@@ -162,7 +133,7 @@ namespace bbtk
     bbSetExecuting(false);
     bbGlobalSetSomeBoxExecuting(wasExecuting);
 
-    return bbGetStatus();
+    return; // bbGetStatus();
 
   }
   //=========================================================================
@@ -222,10 +193,9 @@ namespace bbtk
   
   //=========================================================================
   ///  Sets the data of the input called <name>
-  void AtomicBlackBox::bbSetInput(
-                const std::string &name,
-                Data data, 
-                bool setModified )
+  void AtomicBlackBox::bbSetInput(const std::string &name,
+                                 Data data, 
+                                 bool setModified )
   {
     bbtkDebugMessageInc("data",7,
             "AtomicBlackBox::bbSetInput(\""<<name<<"\",data) ["
@@ -234,22 +204,21 @@ namespace bbtk
     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
     
     if (setModified) 
-        {
-            bbSetModifiedStatus();
-        }
+      {
+       bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
+                               MODIFIED);
+      }
     
     bbtkDebugDecTab("data",7);
   }
   //=========================================================================
   
-    //=========================================================================
+  //=========================================================================
   ///  Sets the data of the input called <name>
-  void AtomicBlackBox::bbBruteForceSetInputPointer
-    (
-                    const std::string &name, 
-                    void* data, 
-                    bool setModified
-    )
+  void AtomicBlackBox::bbBruteForceSetInputPointer(const std::string &name, 
+                                                  void* data, 
+                                                  bool setModified
+                                                  )
   {
     bbtkDebugMessageInc("data",7,
             "AtomicBlackBox::bbBruteForceSetInputPointer(\""
@@ -262,7 +231,8 @@ namespace bbtk
     
     if (setModified) 
       {
-        bbSetModifiedStatus();
+       bbSetStatusAndPropagate(bbGetInputConnectorMap().find(name)->second,
+                               MODIFIED);
       }
     
     bbtkDebugDecTab("data",7);