]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkFactory.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkFactory.cxx
index 036231f9e94cc77f90ecf8683e795c94cb7672d2..82bf038f842dfe7ae2c1ed2eec16dd1cc9d94982 100644 (file)
@@ -4,8 +4,8 @@ Program:   bbtk
 Module:    $RCSfile: bbtkFactory.cxx,v $
 Language:  C++
 
-Date:      $Date: 2008/04/08 06:59:30 $
-Version:   $Revision: 1.31 $
+Date:      $Date: 2008/04/09 11:16:57 $
+Version:   $Revision: 1.32 $
                                                                                 
 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
@@ -748,7 +748,7 @@ namespace bbtk
                                  const DataInfo& typeout,
                                  std::string& adaptor) const
   {
-    bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<"
+    bbtkDebugMessageInc("Kernel",8,"Factory::FindAdaptor(<"
                         <<typein<<">,<"
                         <<typeout<<">)"<<bbtkendl);
     
@@ -793,14 +793,76 @@ namespace bbtk
                                                  adaptor);
        if (b) break; 
       }
-    /*
+    bbtkDebugDecTab("Kernel",7);
+    return b; 
+  }
+  //===================================================================
+
+  //===================================================================
+  /// Creates an instance of a black box of type <type> with name <name>
+  bool Factory::FindWidgetAdaptor2(const DataInfo& typein,
+                                 const DataInfo& typeout,
+                                 std::string& widget,
+                                 std::string& adaptor) const
+  {
+    bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<"
+                        <<typein<<">,<"
+                        <<typeout<<">)"<<bbtkendl);
+    
+    bool b = false;
+    adaptor = widget = "";
+    PackageMapType::const_iterator i;
+    for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+      {
+       b = i->second.mPackage->FindWidgetAdaptor(typein,
+                                                 typeout,
+                                                 widget);
+       if (b) break; 
+      }
     if (!b) 
       {
-       bbtkError("no "<<typein<<" to "<<typeout
-                 <<"> widget adaptor available");
-      } 
-    */
-
+       // Look for a widget adaptor with good nature out
+       bbtkMessage("Kernel",5,
+                   "*** Looking for a two pieces widget adaptor for : "
+                   << typein << "->"<<typeout<<std::endl);
+       for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+         {
+           Package::AdaptorMapType::const_iterator j;
+           for (j=i->second.mPackage->GetAdaptorMap().begin();
+                j!=i->second.mPackage->GetAdaptorMap().end();
+                ++j)
+             {
+               if ( ( j->first.mKind ==  
+                      BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR) &&
+                    //(j->first.mTypeIn == typein) &&
+                    (j->first.mTypeOut.GetNature() == typeout.GetNature() ) 
+                    )
+                 {
+                   widget = j->second->GetTypeName();
+                   bbtkMessage("Kernel",5,
+                               "===> Found first part : "<<widget
+                               << " "<<j->first.mTypeIn<<"->"
+                               <<j->first.mTypeOut<<std::endl);
+                   DataInfo ti( j->first.mTypeOut.GetType(), "");
+                   DataInfo to( typeout.GetType(), "");
+                   b = FindAdaptor( ti, to, adaptor );
+                   if (b) 
+                     {
+                       bbtkMessage("Kernel",5,
+                                   "===> Found second part : "<<adaptor
+                                   <<std::endl);
+                       break;
+                     }
+                   else
+                     {
+                       bbtkMessage("Kernel",5,
+                                   "===> No second part found"<<std::endl);
+                     }
+                 }
+             }
+           if (b) break;
+         }
+      }
     bbtkDebugDecTab("Kernel",7);
     return b; 
   }
@@ -868,6 +930,21 @@ namespace bbtk
   }
   //===================================================================
 
+  //===================================================================
+  void Factory::CheckPackages() const
+  {
+    bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this
+                <<std::endl);
+    PackageMapType::const_iterator i;
+    for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+      {
+       i->second.mPackage->CheckBoxes();
+      }
+    bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this
+               <<" ... OK"<<std::endl);
+  }
+  //===================================================================
+
   //===================================================================
   void Factory::WriteDotFilePackagesList(FILE *ff)
   {