]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkBlackBox.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkBlackBox.cxx
index f9cae866fd95b1742c48865f6ac11260a6d1729b..bb409a1be3297c99c44cd5d4cd698b27fe126a16 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkBlackBox.cxx,v $
 Language:  C++
-Date:      $Date: 2008/02/05 13:23:46 $
-Version:   $Revision: 1.2 $
+Date:      $Date: 2008/03/11 18:46:47 $
+Version:   $Revision: 1.7 $
                                                                                 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
 l'Image). All rights reserved. See doc/license.txt or
@@ -35,6 +35,13 @@ PURPOSE.  See the above copyright notices for more information.
 
 namespace bbtk
 {
+
+//EED
+  static bool bbmgSomeBoxExecuting = false;
+  static bool bbmgFreezeExecution = false;
+  static std::set<BlackBox*> bbmgExecutionList;
+
+
   //=========================================================================
   BlackBox::BlackBox(const std::string &name) 
     : bbmName(name), bbmStatus(MODIFIED), 
@@ -89,7 +96,7 @@ namespace bbtk
                        "=> BlackBox::bbExecute() ["
                        <<bbGetFullName()<<"]"<<std::endl);
 
-    wx::BeginBusyCursor();
+    Wx::BeginBusyCursor();
 
     // If execution frozen : return
     if (bbGlobalGetFreezeExecution()) 
@@ -104,7 +111,7 @@ namespace bbtk
     // Calls the main recursive update method 
     bbBackwardUpdate(0);
 
-    wx::EndBusyCursor();
+    Wx::EndBusyCursor();
 
     bbtkDebugMessageDec("Process",1,
                        "<= BlackBox::bbExecute() ["
@@ -303,7 +310,7 @@ namespace bbtk
   { 
     return ( bbGlobalGetSomeBoxExecuting() 
 #ifdef _USE_WXWIDGETS_
-            || WxBlackBox::bbGlobalIsSomeWindowAlive() 
+            || Wx::IsSomeWindowAlive() 
 #endif
             ); 
   }
@@ -465,10 +472,10 @@ namespace bbtk
       }
   if (reaction) bbGlobalProcessExecutionList();
 
-    bbtkDebugMessageDec("Process",5,
-                       "<= BlackBox::bbSignalOutputModification("
-                       <<output<<") ["
-                       <<bbGetFullName()<<"]"<<std::endl);
+  bbtkDebugMessageDec("Process",5,
+                      "<= BlackBox::bbSignalOutputModification("
+                      <<output<<") ["
+                      <<bbGetFullName()<<"]"<<std::endl);
 
   }  
   //=========================================================================   
@@ -520,7 +527,7 @@ namespace bbtk
                        <<std::endl);   
 
     IOStatus s = UPTODATE;
-    
+
     InputConnectorMapType::iterator i;
     for ( i = bbGetInputConnectorMap().begin(); 
          i!= bbGetInputConnectorMap().end(); ++i) 
@@ -649,28 +656,40 @@ namespace bbtk
     // Looks for the adaptor
     if (bbGetOutputType(output).name() != typeid(std::string).name() ) 
       {
-       BlackBox* a = 0;
-       try
+       // Look for factory 
+       Package* p = bbGetDescriptor()->GetPackage();
+       if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
          {
-           a = NewAdaptor(  
-                          bbGetOutputType(output),
-                          typeid(std::string),
-                          "");
-         } catch (bbtk::Exception e) 
+           Factory* f = *p->GetFactorySet().begin();
+           BlackBox* a = 0;
+           try
+             {
+               a = f->NewAdaptor(  
+                                 bbGetOutputType(output),
+                                 typeid(std::string),
+                                 "");
+             } catch (bbtk::Exception e) 
+             {
+             }
+           if (a!=NULL){
+             //                        bbUpdate();
+             a->bbSetInput("In",bbGetOutput(output));
+             a->bbExecute();
+             v = a->bbGetOutput("Out").unsafe_get<std::string>() ;
+           } else {
+             v="? (no adaptor found)";
+           }
+         }
+       else 
          {
+           v="? (no factory found)";
          }
-       if (a!=NULL){
-         //                    bbUpdate();
-         a->bbSetInput("In",bbGetOutput(output));
-         a->bbExecute();
-         v = a->bbGetOutput("Out").unsafe_get<std::string>() ;
-       } else {
-         v="? (no adaptor found)";
-       }
-      } else {
-      //         bbUpdate();
-      v = bbGetOutput(output).unsafe_get<std::string>() ;
-    }
+      } 
+    else 
+      {
+       //         bbUpdate();
+       v = bbGetOutput(output).unsafe_get<std::string>() ;
+      }
     return v;
   }
   //=========================================================================
@@ -682,28 +701,38 @@ namespace bbtk
     // Looks for the adaptor
     if (bbGetInputType(input) != typeid(std::string)) 
       {
-       BlackBox* a = 0;
-       try
-         {
-           a = NewAdaptor(  
-                          bbGetInputType(input),
-                          typeid(std::string),
-                          "");
-         }catch (bbtk::Exception e) 
+       // Look for factory 
+       Package* p = bbGetDescriptor()->GetPackage();
+       if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
          {
-         }
-       if (a!=NULL)
-         {
-           //                  bbUpdate();
-           a->bbSetInput("In",bbGetInput(input));
-           a->bbExecute();
-           v = a->bbGetOutput("Out").unsafe_get<std::string>() ;
+           Factory* f = *p->GetFactorySet().begin();
+           BlackBox* a = 0;
+           try
+             {
+               a = f->NewAdaptor(  
+                              bbGetInputType(input),
+                              typeid(std::string),
+                              "");
+             }catch (bbtk::Exception e) 
+             {
+             }
+           if (a!=NULL)
+             {
+               //                      bbUpdate();
+               a->bbSetInput("In",bbGetInput(input));
+               a->bbExecute();
+               v = a->bbGetOutput("Out").unsafe_get<std::string>() ;
+             } 
+           else 
+             {
+               v="? (no adaptor found)";
+             }
          } 
        else 
          {
-           v="? (no adaptor found)";
+           v="? (no factory found)";
          }
-      } 
+      }
     else 
       {
        v = bbGetInput(input).unsafe_get<std::string>() ;
@@ -758,17 +787,19 @@ namespace bbtk
                                        bool instanceOrtype,
                                        bool relative_link )
 
-  {
+  { 
     InputConnectorMapType::iterator i;
     // label
     std::string labelStr;
     std::string valueStr("");
-    if (detail==0)
-      {
-       labelStr = bbGetName() ; 
-      } else {
-      labelStr = bbGetName();
-      labelStr = labelStr + "   [" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "]  ";
+
+       if (detail==0) {
+               labelStr = bbGetName() ; 
+//EED 18 Fev 2008
+               labelStr = labelStr + "\\n[" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "]";
+       } else {
+               labelStr = bbGetName();
+               labelStr = labelStr + "   [" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "]  ";
     }
 
     SubsBrackets(labelStr);
@@ -1014,11 +1045,39 @@ namespace bbtk
    }
   //=========================================================================
 
+    bool BlackBox::bbGlobalGetSomeBoxExecuting()
+       { 
+               return bbmgSomeBoxExecuting; 
+       }
+
+    void BlackBox::bbGlobalSetSomeBoxExecuting(bool b) 
+       { 
+               bbmgSomeBoxExecuting = b; 
+       }
+
+    void BlackBox::bbGlobalSetFreezeExecution(bool b) 
+       { 
+               bbmgFreezeExecution = b;
+       }
+
+    bool BlackBox::bbGlobalGetFreezeExecution() 
+       { 
+               return bbmgFreezeExecution; 
+       }
+
+    void BlackBox::bbGlobalAddToExecutionList( BlackBox* b )
+       {  
+               bbmgExecutionList.insert(b); 
+       } 
+
+
   //=========================================================================
   // Static members initialization
+/*EED
   bool BlackBox::bbmgSomeBoxExecuting = false;
   bool BlackBox::bbmgFreezeExecution = false;
   std::set<BlackBox*> BlackBox::bbmgExecutionList;
+*/
    //=========================================================================