]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkComplexBlackBox.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkComplexBlackBox.cxx
index 8c54bc9d7f4715928ffe92ccd141045ccf278f26..012a03f24c743a67d2bb440c32cd45d21d3cecc0 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkComplexBlackBox.cxx,v $
 Language:  C++
-Date:      $Date: 2008/03/07 10:21:30 $
-Version:   $Revision: 1.7 $
+Date:      $Date: 2008/04/08 06:59:29 $
+Version:   $Revision: 1.8 $
                                                                                 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
 l'Image). All rights reserved. See Doc/License.txt or
@@ -231,6 +231,7 @@ namespace bbtk
                        "ComplexBlackBox::bbExecute() ["
                        <<bbGetFullName()<<"]"<<std::endl);
 
+
     Wx::BeginBusyCursor();
     
     if (mExecutionList.size() != 0) 
@@ -256,6 +257,7 @@ namespace bbtk
 
     Wx::EndBusyCursor();
     
+
     bbtkDebugDecTab("Process",1);
     
   }
@@ -295,9 +297,22 @@ namespace bbtk
   IOStatus ComplexBlackBox::bbBackwardUpdate(Connection* caller)
   {
     bbtkDebugMessageInc("Process",1,
-                       "ComplexBlackBox::bbBackwardUpdate("<<caller->GetFullName()<<") ["
+                       "ComplexBlackBox::bbBackwardUpdate("
+                       <<(caller?caller->GetFullName():"0")<<") ["
                        <<bbGetFullName()<<"]"<<std::endl);
 
+    if (caller==0)
+      {
+       bbtkInternalError("ComplexBlackBox::bbBackwardUpdate called with caller=0");
+      }
+
+    if (bbGetExecuting()) 
+      {
+       bbtkWarning(bbGetFullName()<<" : Cyclic execution stopped");
+       return UPTODATE;
+      }
+    bbSetExecuting(true);
+
     IOStatus s = UPTODATE;
     const BlackBoxDescriptor::OutputDescriptorMapType& omap 
       = bbGetDescriptor()->GetOutputDescriptorMap(); 
@@ -312,7 +327,22 @@ namespace bbtk
        BlackBox* b = bbUnsafeGetBlackBox ( d->GetTarget() );
        // Calls BackwardUpdate on it
        bbtkDebugMessageInc("Process",2,"Internal box connected to output : "<<d->GetTarget()<<std::endl);
-       IOStatus s1 = b->bbBackwardUpdate(caller);
+       // Because internal box can also be a complex box we have to 
+       // temporarily change the connection BlackBoxFromOutput to the 
+       // mapped one
+       
+       //      std::string oldout = caller->GetBlackBoxFromOutput();
+       //      std::cout << "oldout = "<<oldout<<std::endl;
+       //      std::cout << "tmpout = "<<d->GetOutput()<<std::endl;
+       //      caller->SetBlackBoxFromOutput(d->GetOutput());
+       //
+       Connection newcaller(*caller);
+       newcaller.SetBlackBoxFromOutput(d->GetOutput());
+       IOStatus s1 = b->bbBackwardUpdate(&newcaller);
+       newcaller.Clear();
+       // restore old output
+       //      caller->SetBlackBoxFromOutput(oldout);
+
        // ??? STATUS OF CBBs ???
        // ??? Here it is only the final status of the boxes connected to the output 
        if (s1==MODIFIED) s=MODIFIED;
@@ -323,41 +353,12 @@ namespace bbtk
        bbtkError("Connection '"<<caller->GetFullName()<<"' does not point to a valid output of the complex box !");
       }
     bbtkDebugDecTab("Process",1);
-    return s;
-  }
-  //==================================================================
-  
-  /*
-  //==================================================================
-  void ComplexBlackBox::bbForwardUpdate(Connection* caller)
-  { 
-    bbtkDebugMessageInc("Process",1,
-                       "ComplexBlackBox::bbForwardUpdate("<<caller->GetFullName()<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
 
-    const BlackBoxDescriptor::InputDescriptorMapType& imap 
-      = bbGetDescriptor()->GetInputDescriptorMap(); 
-    BlackBoxDescriptor::InputDescriptorMapType::const_iterator i 
-      = imap.find(caller->GetBlackBoxToInput());
-    if (i!=imap.end())
-      {        
-       // Cast the BBOutputDescriptor into a ComplexBBOutputDescriptor
-       ComplexBlackBoxInputDescriptor* d = 
-         (ComplexBlackBoxInputDescriptor*)i->second;
-       // Get the internal box 
-       BlackBox* b = bbUnsafeGetBlackBox ( d->GetTarget() );
-       // Calls ForwardUpdate on it
-       bbtkDebugMessage("Process",2,"-> Internal box connected to input : "<<d->GetTarget()<<std::endl);
-       b->bbForwardUpdate(caller);
-      }
-    else 
-      {
-       bbtkError("Connection '"<<caller->GetFullName()<<"' does not point to a valid input of the complex box !");
-      }
-    bbtkDebugDecTab("Process",1);
+    bbSetExecuting(false);
+
+    return s;
   }
   //==================================================================
-  */
 
 
   //==================================================================
@@ -955,10 +956,12 @@ namespace bbtk
     } // if parentblackbox
   }
   //=========================================================================
+  
 
-  /*
 
 
+  /*
+
   //=======================================================================
   /// Generates the list of the packages of which its depends 
   /// (cause an internal box belongs to it)