]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkFactory.cxx
Bug #1498
[bbtk.git] / kernel / src / bbtkFactory.cxx
index 627bc80881b1e99ac4b112dbf8244d543c8a9718..7c55c7f00ed9fd7dc33769cc2503098364e725b2 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkFactory.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/10/05 22:44:48 $
-  Version:   $Revision: 1.46 $
+  Date:      $Date: 2012/10/16 06:31:04 $
+  Version:   $Revision: 1.53 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -140,6 +140,8 @@ namespace bbtk
   
   void Factory::LoadPackage( const std::string& name )
   {
+         
+         
   // Note : in the following :
   // name : the user supplied name
   //      - abreviated name    e.g.       pkg   pkg.so   libbpkg   libbbpkg.so
@@ -149,6 +151,8 @@ namespace bbtk
   //
   // lastname : string before the last / (if any), or user supplied name
          
+        
+         
        if(name != ""){
                bbtkDebugMessageInc("kernel",7,"Factory::LoadPackage(\""<<name<<"\")"<<std::endl);
                bbtkMessage("debug",1,"Factory::LoadPackage(\""<<name<<"\")"<<std::endl);
@@ -158,7 +162,9 @@ namespace bbtk
                std::string pkgname;  // e.g. libbb<pkgname>.so
 
                std::string upath;
+
                pkgname = Utilities::ExtractPackageName(name,upath);
+                               
                bbtkMessage("debug",1,"Package name ["<<pkgname<<"]"<<std::endl);
                bbtkMessage("debug",1,"Package path ["<<upath<<"]"<<std::endl);
 
@@ -166,6 +172,14 @@ namespace bbtk
                PackageMapType::iterator iUnload;
                iUnload = mPackageMap.find(pkgname);
 
+//EED Debuging message
+     std::cout << "EED Factory::LoadPackage " <<  std::endl;
+//             PackageMapType::iterator it;
+//             for ( it=mPackageMap.begin() ; it != mPackageMap.end(); it++ )
+//                     std::cout << (*it).first << " ";
+//             std::cout << std::endl;
+
+               
                if (iUnload != mPackageMap.end())
                {
                  bbtkMessage("output",2,"["<< pkgname <<"] already loaded" << std::endl);
@@ -179,8 +193,6 @@ namespace bbtk
        // *all* the cases. JP
        //==================================================
 
-       //std::cout << "upath [" << upath << "]" << std::endl;
-
                bool ok = false;
                bool foundFile = false;
 
@@ -499,6 +511,9 @@ namespace bbtk
                         p->GetName()<<"\")"<<std::endl);
 
     p->AddFactory(GetThisPointer<Factory>());
+         
+printf("EED Factory::InsertPackage %s\n", p->GetName().c_str() );        
+         
     mPackageMap[p->GetName()] = p;
 
     bbtkDebugDecTab("kernel",9);
@@ -533,6 +548,22 @@ namespace bbtk
   //===================================================================
   
 
+//     ups3 EED borrame        
+       std::string Factory::GetPackageNameOfaBlackBox(std::string boxType)
+       {
+               std::string result="<void bbtk package name>";
+               PackageMapType::const_iterator i;
+               for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+               {
+                       if ( i->second->ifBoxExist( boxType ) == true)
+                       {
+                               result = i->first;
+                       }
+               }
+               return result;
+       }
+       
+       
   //===================================================================
   /// Creates an instance of a black box of type <type> with name <name>
   BlackBox::Pointer Factory::NewBlackBox(const std::string& type, 
@@ -833,7 +864,6 @@ namespace bbtk
 
  void Factory::ShowGraphTypes(const std::string& name) const
  {
-
    bool found = false;
    PackageMapType::const_iterator i;
    for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
@@ -888,76 +918,74 @@ namespace bbtk
     std::string title;
 
     typedef std::map<std::string, 
-      std::vector<BlackBoxDescriptor::Pointer> > IndexType;
+                     std::vector<BlackBoxDescriptor::Pointer> > IndexType;
     IndexType index;
     // Builds the index map
     PackageMapType::const_iterator i;
     for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
-      {
-       Package::Pointer pack = i->second;
-       if (pack->GetName()=="user") continue;
-       Package::DescriptorMapType::const_iterator j;
-       for (j = pack->GetDescriptorMap().begin(); 
-            j!= pack->GetDescriptorMap().end(); 
-            ++j)
-         {
+       {
+               Package::Pointer pack = i->second;
+               if (pack->GetName()=="user") continue;
+               Package::DescriptorMapType::const_iterator j;
+               for (j = pack->GetDescriptorMap().begin(); 
+                       j!= pack->GetDescriptorMap().end(); 
+                       ++j)
+               {
            
            // Skip adaptors 
-           if ( type==Adaptors )
-             {  
-               if (j->second->GetKind() == BlackBoxDescriptor::STANDARD )
-                 continue;
-             }
-           else 
-             if (j->second->GetKind() != BlackBoxDescriptor::STANDARD )
-               continue;
+                       if ( type==Adaptors )
+                       {  
+                               if (j->second->GetKind() == BlackBoxDescriptor::STANDARD )
+                               continue;
+                       }
+                       else 
+                               if (j->second->GetKind() != BlackBoxDescriptor::STANDARD )
+                               continue;
 
-           std::vector<std::string> keys;
-           if (type==Packages)
-             {
-               std::string k("");
-               k += pack->GetName();
-               keys.push_back(k);
-               title = "Boxes by package";
-             }
-           else if ((type==Initials) || (type==Adaptors))
-             {
-               std::string init(" ");
-               init[0] =  std::toupper(j->second->GetTypeName()[0]);
-               keys.push_back(init);
-               title = "Alphabetical list";
-             }
-           else if (type==Categories)
-             {
-               // Split the category string 
-               std::string delimiters = ";,";
-               Utilities::SplitString(j->second->GetCategory(),
-                                      delimiters,keys);
-               if (keys.size()==0) 
-                 keys.push_back(" NONE");
-               title = "Boxes by category";
-             }
-    
-           
-           std::vector<std::string>::const_iterator k;
-           for (k=keys.begin(); k!=keys.end(); ++k )
-             {
-               IndexType::iterator p;
-               p = index.find(*k);
-               if (p != index.end()) 
-                 {
-                   p->second.push_back(j->second);
-                 }
-               else 
-                 {
-                   std::vector<BlackBoxDescriptor::Pointer> v;
-                   v.push_back(j->second);
-                   index[*k] = v;
-                 }
-             }
-           
-         }
-      }   
+                       std::vector<std::string> keys;
+                       if (type==Packages)
+                       {
+                               std::string k("");
+                               k += pack->GetName();
+                               keys.push_back(k);
+                               title = "Boxes by package";
+                       }
+                       else if ((type==Initials) || (type==Adaptors))
+                       {
+                               std::string init(" ");
+                               init[0] =  std::toupper(j->second->GetTypeName()[0]);
+                               keys.push_back(init);
+                               title = "Alphabetical list";
+                       }
+                       else if (type==Categories)
+                       {
+                       // Split the category string 
+                       std::string delimiters = ";,";
+                       Utilities::SplitString(j->second->GetCategory(),
+                                          delimiters,keys);
+                       if (keys.size()==0) 
+                               keys.push_back(" NONE");
+                               title = "Boxes by category";
+                       }
+
+                       std::vector<std::string>::const_iterator k;
+                       for (k=keys.begin(); k!=keys.end(); ++k )
+                       {
+                               IndexType::iterator p;
+                               p = index.find(*k);
+                               if (p != index.end()) 
+                               {
+                                       p->second.push_back(j->second);
+                               }
+                               else 
+                               {
+                                       std::vector<BlackBoxDescriptor::Pointer> v;
+                                       v.push_back(j->second);
+                                       index[*k] = v;
+                               }
+                       }
+               }
+       }   
     // Creates the file 
     //---------------------
     // Open output file
@@ -1002,7 +1030,7 @@ namespace bbtk
     IndexType::iterator ii;
     for (ii=index.begin();ii!=index.end();++ii)
       {
-       s << "<a href=\"#"<<ii->first<<"\">"<<ii->first<<"</a>&nbsp;&nbsp;";    
+               s << "<a href=\"#"<<ii->first<<"\">"<<ii->first<<"</a>&nbsp;&nbsp;";    
       }
 
     for (ii=index.begin();ii!=index.end();++ii)
@@ -1018,9 +1046,14 @@ namespace bbtk
            s << "&nbsp;&nbsp;-&nbsp;&nbsp;\n"; 
 
            s << "<a name=\"doxygen\"></a>\n"; 
-//EED 26Mars2009                 
+
+//EED 26Mars2009
+       /*JCP 19 Nov 2009
                std::string bin_path = bbtk::ConfigurationFile::GetInstance().Get_bin_path();
            s << "<a href=" << bin_path <<"/../share/bbtk/doc/doxygen/" << ii->first << "/main.html>(Doxygen documentation of the source)</a>\n"; 
+       JCP 19 Nov 2009*/
+               std::string bin_path = bbtk::ConfigurationFile::GetInstance().Get_bin_path();           
+           s << "<a href=" << bin_path <<"/../share/bbtk/doc/doxygen/" << ii->first << "/main.html>(Doxygen documentation of the source)</a>\n"; 
          }
        else 
          {