]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkConnection.cxx
MagicBox : support of data synchronization + various related fixes
[bbtk.git] / kernel / src / bbtkConnection.cxx
index 38051fbff9e41ac2b83df54e4bf2e5e53062ca38..37c0eb6be1448122aacd7f025324e4f973e34329 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkConnection.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/08 14:02:15 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2009/03/30 14:42:16 $
+  Version:   $Revision: 1.20 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -116,9 +116,7 @@ Connection::Connection(BlackBox::Pointer from, const std::string& output,
       {
        if ( from->bbGetOutputType(output) == typeid(Data) )
          {
-           bbtkWarning("Connection '"
-                       <<GetFullName()
-                       <<"' : '"<<from->bbGetName()<<"."<<output
+           bbtkWarning("Connection: '"<<from->bbGetName()<<"."<<output
                        <<"' is of type <"
                        <<HumanTypeName<Data>()
                        <<"> : type compatibility with '"
@@ -338,48 +336,53 @@ Connection::Connection(BlackBox::Pointer from, const std::string& output,
   //==================================================================
   
   //==================================================================
-  /// Backward Update
-  void Connection::BackwardUpdate()
+  /// Recursive execution
+  void Connection::RecursiveExecute()
   {
-    bbtkDebugMessage("process",5,
-                    "===> Connection::BackwardUpdate() ["
+    bbtkDebugMessage("process",4,
+                    "===> Connection::RecursiveExecute() ["
                     <<GetFullName()<<"]"<<std::endl);
 
-    mFrom->bbBackwardUpdate(GetThisPointer<Connection>());
+    /*
+    // If box from already executing : nothing to do
+    if (mFrom->bbGetExecuting()) 
+      {
+       bbtkDebugMessage("process",3,
+                        " -> "<<mFrom->bbGetName()
+                        <<" already executing : abort"<<std::endl);
+       return; 
+
+      }
+    */
+
+    mFrom->bbRecursiveExecute(GetThisPointer<Connection>());
 
     TransferData();
 
     // Transfer status
     IOStatus s = MODIFIED;
     if ( mFrom->bbGetOutputConnector(mOutput).GetStatus() == OUTOFDATE) 
-      s = OUTOFDATE,
+      {
+       s = OUTOFDATE;
+      }
     mTo->bbGetInputConnector(mInput).SetStatus(s);
-
-    bbtkDebugMessage("process",5,
-                    "<=== Connection::BackwardUpdate() ["
+    
+    bbtkDebugMessage("process",4,
+                    " --> '"<<mTo->bbGetName()<<"."<<mInput
+                    <<" ["<<&mTo->bbGetInputConnector(mInput)<<"] "
+                    <<"' new status '"
+                    <<GetIOStatusString(s)
+                    <<"'"
+                    << std::endl);
+
+    bbtkDebugMessage("process",4,
+                    "<=== Connection::RecursiveExecute() ["
                     <<GetFullName()<<"]"<<std::endl);
-    return; // s;
+    return; 
   }
   //==================================================================
 
-  /*
-  //==================================================================
-  /// Forward Update
-  void Connection::ForwardUpdate()
-  {
-    bbtkDebugMessageInc("process",2,
-                       "Connection::ForwardUpdate() ["
-                       <<GetFullName()<<"]"<<std::endl);
-
-  
-    TransferData();
-
-    mTo->bbForwardUpdate(this);
 
-    bbtkDebugDecTab("process",2);
-  }
-  //==================================================================
-  */
 
   //==================================================================
   /// Transfers the data from the source output to the target input
@@ -414,8 +417,14 @@ Connection::Connection(BlackBox::Pointer from, const std::string& output,
                         <<HumanTypeName(mTo->bbGetInputType(mInput))
                         <<">"<<std::endl);
        
+       // 0) If from any contents void : nothing to do 
+       if (mFrom->bbGetOutput(mOutput).type() == typeid(void)) 
+         {
+           bbtkDebugMessage("data",3,
+                            " -> Source is void : nothing to transfer!"<<std::endl);
+         }
        // 1) Test strict type matching between any content and target
-       if (mFrom->bbGetOutput(mOutput)
+       else if (mFrom->bbGetOutput(mOutput)
            .contains( mTo->bbGetInputType(mInput) ) )
          {
            bbtkDebugMessage("data",3,
@@ -493,31 +502,15 @@ Connection::Connection(BlackBox::Pointer from, const std::string& output,
 
   }
   //==================================================================
-  
-  /*
-  //==================================================================
-  /// Modified
-  void Connection::SetModifiedStatus()
-  {
-    bbtkDebugMessage("modified",2,
-                    "==> Connection::SetModifiedStatus() ["
-                    <<GetFullName()<<"]"<<std::endl);
-    
-    if (mAdaptor) mAdaptor->bbSetModifiedStatus();
-    
-    mTo->bbSetModifiedStatus(  mTo->bbGetInputConnectorMap().find(mInput)->second );
-    
-  }
-  //==================================================================
-  */
+
   //==================================================================
   /// From.Output change propagation
   void Connection::OnOutputChange(bbtk::BlackBox::Pointer, const std::string&, 
                                  IOStatus status)
   {
     bbtkDebugMessage("change",2,
-                    "==> Connection::OnOutputChange("<<status<<") ["
+                    "==> Connection::OnOutputChange("
+                    <<GetIOStatusString(status)<<") ["
                     <<GetFullName()<<"]"<<std::endl);
     if (mAdaptor) 
       {