]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkBlackBox.cxx
Global factory in course of removal... does not compile but have to commit to continu...
[bbtk.git] / kernel / src / bbtkBlackBox.cxx
index 7955ccfc4ab4a0b1b77f13ae4246c6675c870d3c..94610b0645b0cde78dedb497d4466e5d10522ff3 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkBlackBox.cxx,v $
 Language:  C++
-Date:      $Date: 2008/02/20 16:05:38 $
-Version:   $Revision: 1.5 $
+Date:      $Date: 2008/03/07 08:40:14 $
+Version:   $Revision: 1.6 $
                                                                                 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
 l'Image). All rights reserved. See doc/license.txt or
@@ -649,28 +649,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 +694,38 @@ namespace bbtk
     // Looks for the adaptor
     if (bbGetInputType(input) != typeid(std::string)) 
       {
-       BlackBox* a = 0;
-       try
+       // Look for factory 
+       Package* p = bbGetDescriptor()->GetPackage();
+       if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
          {
-           a = 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>() ;
+           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>() ;