]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkPackage.cxx
BUG HTML in windows + Cast float int
[bbtk.git] / kernel / src / bbtkPackage.cxx
index 7b50aefd251f3e9ef3503a424fc8c3de3623a6d4..7d70c2511faefa7bdbd63ba5935f5932b440996b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/01/30 12:14:43 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/02/18 10:41:02 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
@@ -41,11 +41,11 @@ namespace bbtk
       mVersion(version),
       mBBTKVersion(BBTKVersion)
   {
-    std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_doc_tmp();
+    std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
     char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
     std::string url = default_doc_dir; 
     if (c != '/' && c !='\\') url = url + "/";
-    url = url +  "doc_tmp/" + name + "/index.html";    
+    url = url +  "temp_dir/" + name + "/index.html";    
     
     SetDocURL(url);
     SetDocRelativeURL("Relative url not set");
@@ -61,7 +61,7 @@ namespace bbtk
 
     //    std::cout  << "   url=["<<url<<"]"<<std::endl;
     //    std::cout  << "relurl=["<<relurl<<"]"<<std::endl;
-    bbtkDebugMessage("Core",7,"Package::Package(\""<<name<<"\")"<<bbtkendl);
+    bbtkDebugMessage("Kernel",7,"Package::Package(\""<<name<<"\")"<<bbtkendl);
   }
   //==========================================================================
 
@@ -71,7 +71,7 @@ namespace bbtk
   /// Dtor
   Package::~Package()
   {
-    bbtkDebugMessageInc("Core",7,"Package::~Package(\""<<mName<<"\")"<<bbtkendl);
+    bbtkDebugMessageInc("Kernel",7,"Package::~Package(\""<<mName<<"\")"<<bbtkendl);
     BlackBoxMapType::const_iterator i;
     for (i=mBlackBoxMap.begin();
          i!=mBlackBoxMap.end();
@@ -89,7 +89,7 @@ namespace bbtk
          delete j->second;
       }
     */ 
-    bbtkDebugDecTab("Core",7);
+    bbtkDebugDecTab("Kernel",7);
   }
   //==========================================================================
 
@@ -100,16 +100,16 @@ namespace bbtk
   BlackBox* Package::NewBlackBox(const std::string& type, 
                                    const std::string& name) const
   {
-    bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl);
+    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl);
     
     BlackBoxMapType::const_iterator i = mBlackBoxMap.find(type);
     if (i == mBlackBoxMap.end())  
     {
-          bbtkDebugDecTab("Core",8);
+          bbtkDebugDecTab("Kernel",8);
           return 0;
     }
     BlackBox* bb =i->second->CreateInstance(name);
-    bbtkDebugDecTab("Core",8);
+    bbtkDebugDecTab("Kernel",8);
     return bb;   
 
   }
@@ -124,7 +124,7 @@ namespace bbtk
                                   TypeInfo typeout,
                                   const std::string& name) const
   {
-    bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<
+    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
                        ">::NewAdaptor(<"
                        <<TypeName(typein)<<">,<"
                        <<TypeName(typeout)<<">,\""
@@ -134,11 +134,11 @@ namespace bbtk
     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
     if (i == mAdaptorMap.end())  
       {
-       bbtkDebugDecTab("Core",8);
+       bbtkDebugDecTab("Kernel",8);
        return 0;
       }
     BlackBox* bb =i->second->CreateInstance(name);
-    bbtkDebugDecTab("Core",8);
+    bbtkDebugDecTab("Kernel",8);
     return bb;   
 
   }
@@ -151,13 +151,13 @@ namespace bbtk
   /// Registers a black box descriptor in the package
   bool Package::RegisterBlackBox(BlackBoxDescriptor* d) 
   {
-    bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
+    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
     
     mBlackBoxMap[d->GetTypeName()] = d;
     d->SetPackage(this);
     
     // If it is a default adaptor, also register it in the adaptors map
-    if ( d->GetCategory() == BlackBoxDescriptor::DEFAULT_ADAPTOR) 
+    if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR) 
       {
        TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
        TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
@@ -165,7 +165,7 @@ namespace bbtk
        AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
        if (i == mAdaptorMap.end())  
          {
-           bbtkDebugMessage("Core",8,"The box is an adaptor, inserting it in adaptors map ..."<<std::endl);   
+           bbtkDebugMessage("Kernel",8,"The box is an adaptor, inserting it in adaptors map ..."<<std::endl);   
            mAdaptorMap[key] = d;
          }
        // If already an adaptor registered : error
@@ -179,7 +179,7 @@ namespace bbtk
          }
       }
     
-    bbtkDebugDecTab("Core",8);
+    bbtkDebugDecTab("Kernel",8);
    
     return true;
   }
@@ -190,12 +190,12 @@ namespace bbtk
   /// UnRegisters a black box descriptor from the package
   void Package::UnRegisterBlackBox(const std::string& name) 
   {
-    bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::UnRegisterBlackBox(\""<<name<<"\")"<<std::endl);
+    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::UnRegisterBlackBox(\""<<name<<"\")"<<std::endl);
     // Looking into the bb map
     BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
     if (i == mBlackBoxMap.end())  
     {
-       bbtkDebugDecTab("Core",8);
+       bbtkDebugDecTab("Kernel",8);
        bbtkError("UnRegister : The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
      }
     mBlackBoxMap.erase(i);
@@ -207,7 +207,7 @@ namespace bbtk
          mAdaptorMap.erase(j);
       }
     */    
-    bbtkDebugDecTab("Core",8);    
+    bbtkDebugDecTab("Kernel",8);    
   }
   //==========================================================================
 
@@ -215,12 +215,12 @@ namespace bbtk
   /// Changes the name of a black box type
   void Package::ChangeBlackBoxName( const std::string& oldname, const std::string& newname )
   { 
-    bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::ChangeBlackBoxName(\""<<oldname<<"\",\""<<newname<<"\")"<<std::endl);
+    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::ChangeBlackBoxName(\""<<oldname<<"\",\""<<newname<<"\")"<<std::endl);
     // Looking into the bb map
     BlackBoxMapType::iterator i = mBlackBoxMap.find(oldname);
     if (i == mBlackBoxMap.end())  
       {
-         bbtkDebugDecTab("Core",8);
+         bbtkDebugDecTab("Kernel",8);
          bbtkError("ChangeBlackBoxName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">");
       }
 
@@ -228,7 +228,7 @@ namespace bbtk
     mBlackBoxMap[newname] = i->second;
     mBlackBoxMap.erase(i);
 
-    bbtkDebugDecTab("Core",8);    
+    bbtkDebugDecTab("Kernel",8);    
   }
   //==========================================================================
 
@@ -238,7 +238,7 @@ namespace bbtk
   /// Registers an adaptor descriptor in the package
   bool Package::RegisterAdaptor(BlackBoxDescriptor* d) 
   {
-    bbtkDebugMessage("Core",8,"Package<"<<GetName()<<">::RegisterAdaptor(\""<<d->GetTypeName()<<"\")"<<std::endl);
+    bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterAdaptor(\""<<d->GetTypeName()<<"\")"<<std::endl);
     
     TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
     TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
@@ -257,7 +257,7 @@ namespace bbtk
   {
     unsigned int lmax = 0;
     std::vector<std::string> names;
-    std::vector<std::string> categs;
+    std::vector<std::string> kinds;
     std::vector<std::string> descrs;
 
     BlackBoxMapType::const_iterator i;
@@ -266,25 +266,25 @@ namespace bbtk
         ++i) 
       {
        if ( adaptors || 
-            ( i->second->GetCategory() == BlackBoxDescriptor::STANDARD) ) 
+            ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) ) 
          {
            std::string name("  ");
            name += i->second->GetTypeName();
            names.push_back(name);
 
-           std::string categ;
-           if ( i->second->GetCategory() == BlackBoxDescriptor::ADAPTOR )
+           std::string kind;
+           if ( i->second->GetKind() == BlackBoxDescriptor::ADAPTOR )
              {
-               categ = std::string("[A]");
+               kind = std::string("[A]");
              }
-           else if ( i->second->GetCategory() == 
+           else if ( i->second->GetKind() == 
                      BlackBoxDescriptor::DEFAULT_ADAPTOR )
              {
-               categ = std::string("[DA]");
+               kind = std::string("[DA]");
              }
-           categs.push_back(categ);
+           kinds.push_back(kind);
 
-           unsigned int l = name.size()+categ.size();
+           unsigned int l = name.size()+kind.size();
            if (l>lmax) lmax = l;
 
            std::string descr;
@@ -301,7 +301,7 @@ namespace bbtk
     std::string offs;
     offs.append(lmax+3,' ');
     std::vector<std::string>::iterator ni,ci,di;
-    for (ni = names.begin(), ci = categs.begin(), di = descrs.begin();
+    for (ni = names.begin(), ci = kinds.begin(), di = descrs.begin();
         ni != names.end(); ++ni, ++ci, ++di)
       {
        std::string space;
@@ -331,11 +331,11 @@ namespace bbtk
         i!=mBlackBoxMap.end();
         ++i) 
       {
-       if ( i->second->GetCategory() != BlackBoxDescriptor::STANDARD ) 
+       if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD ) 
          {
            bbtkMessage("Help",1,
                        "  "<<i->second->GetTypeName());
-           if ( i->second->GetCategory() == 
+           if ( i->second->GetKind() == 
                 BlackBoxDescriptor::DEFAULT_ADAPTOR )
              {
                bbtkMessage("Help",1,
@@ -374,18 +374,18 @@ namespace bbtk
   /// Prints help on a black box
   void Package::HelpBlackBox(const std::string& name, bool full) const
   {
-    bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
+    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
                        <<name<<"\")"<<bbtkendl);
 
     BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
     if (i == mBlackBoxMap.end())  
       {
-       bbtkDebugDecTab("Core",8);
+       bbtkDebugDecTab("Kernel",8);
        bbtkError("The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
       }
     //    bbtkMessage("Help",1,"["<<GetName()<<"] ");
     i->second->GetHelp(full);
-    bbtkDebugDecTab("Core",8);
+    bbtkDebugDecTab("Kernel",8);
 
   }
   //==========================================================================
@@ -395,16 +395,16 @@ namespace bbtk
   /// Returns true iff the package contains the box of name boxname
   bool Package::ContainsBlackBox(const std::string& name) const 
   {
-    bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
+    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
                        <<name<<"\")"<<bbtkendl);
     
     BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
     if (i == mBlackBoxMap.end())  
     {
-      bbtkDebugDecTab("Core",8);
+      bbtkDebugDecTab("Kernel",8);
       return false;
     }
-    bbtkDebugDecTab("Core",8);
+    bbtkDebugDecTab("Kernel",8);
     return true;
   }
   //==========================================================================
@@ -421,7 +421,7 @@ namespace bbtk
                               int level,
                               bool relative_link ) const
   {
-    bbtkDebugMessageInc("Core",9,"Package<"<<GetName()<<">::CreateHtmlPage(\""
+    bbtkDebugMessageInc("Kernel",9,"Package<"<<GetName()<<">::CreateHtmlPage(\""
                        <<filename<<"\")"<<bbtkendl);
 
     //---------------------
@@ -507,7 +507,7 @@ namespace bbtk
        s << "<TR><TD style='vertical-align: top;'><b> Author(s) </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'>  " 
          << GetAuthor() << "</TD></TR>\n";
        s << "<TR><TD style='vertical-align: top;'><b> Author(s) </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'>  " 
-         << GetKeyword() << "</TD></TR>\n";
+         << GetCategory() << "</TD></TR>\n";
        s << "<TR><TD style='vertical-align: top;'><b> Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 
          << GetVersion() << "</TD></TR>\n";
        s << "<TR><TD style='vertical-align: top;'><b> bbtk Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 
@@ -527,16 +527,17 @@ namespace bbtk
     BlackBoxMapType::const_iterator i;
     for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i) 
       {
-       if ( i->second->GetCategory() != BlackBoxDescriptor::STANDARD) 
+       if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD) 
          continue;
        
        std::string name = i->second->GetTypeName();
        Utilities::html_format(name);
        std::string descr = i->second->GetDescription();
+       Utilities::html_format(descr);
 
         s << "<TR>";
        s << "<TD style='vertical-align: top;'>";
-       s << "<li><a name=\"toc_"<<name
+       s << "&nbsp;&nbsp;&nbsp;<a name=\"toc_"<<name
          <<"\" href=\"#"<<name<<"\">"
          <<name<<"</a>";
        s << "</TD> ";
@@ -546,7 +547,7 @@ namespace bbtk
     s << "</TABLE>\n";
     
     
-    s << "</li></ul>\n";
+    s << "</ul>\n";
     s << "</div>\n";
     
     //-------------------
@@ -561,7 +562,7 @@ namespace bbtk
        s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
        for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end();++i) 
          {
-           if ( i->second->GetCategory() == BlackBoxDescriptor::STANDARD) 
+           if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) 
              continue;
     
            std::string name = i->second->GetTypeName();
@@ -570,7 +571,7 @@ namespace bbtk
     
            s << "<TR>";
            s << "<TD style='vertical-align: top;'>";
-           s << "<li><a name=\"toc_"<<name
+           s << "&nbsp;&nbsp;&nbsp;<a name=\"toc_"<<name
              <<"\" href=\"#"<<name<<"\">"
              <<name<<"</a>";
            s << "</TD> ";
@@ -579,7 +580,7 @@ namespace bbtk
          }    
        s << "</TABLE>\n";
 
-       s << "</li></ul>\n";
+       s << "</ul>\n";
        s << "</div>\n";
       }
     
@@ -601,9 +602,11 @@ namespace bbtk
     // Computes output directory from filename to pass it to 
     // BlackBoxDescriptor::InsertHtmlHelp
     std::string dir;
-    std::string::size_type slash_position = 
-      filename.find_last_of(ConfigurationFile::GetInstance().Get_file_separator ());
-    if (slash_position != std::string::npos) {
+
+    std::string::size_type slash_position = filename.find_last_of("/\\");
+
+
+       if (slash_position != std::string::npos) {
       if (slash_position == 0)
          slash_position = 1;  
       dir = filename.substr(0,slash_position);
@@ -624,8 +627,9 @@ namespace bbtk
     ptm = gmtime ( &rawtime );
 
     s << "<p><hr>\n";
-    s << "Automatically generated by <b>"<<caller<<"</b> from <b>"
-      <<source<<"</b> on "
+    s << "Automatically generated by <b>"<<caller<<"</b> "//from <b>"
+      //      <<source<<"</b>
+      <<"on "
       << ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900 
       << " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n";
     s << "</body></html>\n"; 
@@ -633,7 +637,7 @@ namespace bbtk
     //----------------------
 
     // End
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
   }
   //==========================================================================
 }