]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkConfigurationFile.cxx
no message
[bbtk.git] / kernel / src / bbtkConfigurationFile.cxx
index 4fab8d8ec74d841fe00f47ab0a283afb827b69a9..8e2d78ce31d6b5b30c145a4e3cd497b9813d5b39 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkConfigurationFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/01/28 13:20:32 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2009/12/08 14:10:36 $
+  Version:   $Revision: 1.32 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -54,18 +54,37 @@ namespace bbtk
   ConfigurationFile::ConfigurationFile()
   {
 
-    mFile_separator = VALID_FILE_SEPARATOR;
+       mFile_separator = VALID_FILE_SEPARATOR;
     
     // ==> Set system paths 
     mBin_path = Utilities::GetExecutablePath();
-    
+
+         
+         
+         
+/*     EED 23 Mars 2009  
 #ifdef MACOSX
     mInstall_path = mBin_path + "/../../../..";
 #else
     mInstall_path = mBin_path + "/..";
 #endif
-    
-    
+*/    
+#ifdef MACOSX
+         
+         std::string macPath("Contents/MacOS"); 
+         int sbp = mBin_path.length();
+         int smp = macPath.length();
+         if (mBin_path.compare( sbp-smp, smp, macPath )==0 )
+         {
+                 mBin_path = mBin_path + "/../../..";
+         }
+         
+         
+#endif   
+         mInstall_path = mBin_path + "/..";
+
+         
+         
     // The relative path to the doc folder (=BBTK_DOC_REL_PATH)
     //    mDoc_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH);
     // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
@@ -97,11 +116,11 @@ namespace bbtk
                        INVALID_FILE_SEPARATOR,
                        VALID_FILE_SEPARATOR);
     
-    bbtkMessage("Config",1," ==> bin    : '"<<mBin_path<<"'"<<std::endl);
-    bbtkMessage("Config",1," ==> prefix : '"<<mInstall_path<<"'"<<std::endl);
-    bbtkMessage("Config",1," ==> doc    : '"<<mDoc_path<<"'"<<std::endl);
-    bbtkMessage("Config",1," ==> bbs    : '"<<mBbs_path<<"'"<<std::endl);
-    bbtkMessage("Config",1," ==> data   : '"<<mData_path<<"'"<<std::endl);
+    bbtkMessage("config",1," ==> bin    : '"<<mBin_path<<"'"<<std::endl);
+    bbtkMessage("config",1," ==> prefix : '"<<mInstall_path<<"'"<<std::endl);
+    bbtkMessage("config",1," ==> doc    : '"<<mDoc_path<<"'"<<std::endl);
+    bbtkMessage("config",1," ==> bbs    : '"<<mBbs_path<<"'"<<std::endl);
+    bbtkMessage("config",1," ==> data   : '"<<mData_path<<"'"<<std::endl);
 
 
 
@@ -173,7 +192,7 @@ namespace bbtk
     
     if ( Utilities::FileExists( configXmlFullPathName ))
       {
-       bbtkMessage("Config",1, "ConfigurationFile : [" << configXmlFullPathName << 
+       bbtkMessage("config",1, "ConfigurationFile : [" << configXmlFullPathName << 
                    "] found in current directory" << std::endl); 
        //Read(configXmlFullPathName.c_str());
        // traiter le fichier local     
@@ -221,50 +240,55 @@ namespace bbtk
     std::string filename = Utilities::MakeUserSettingsFullFileName("doc/help_contents.html");
     if (!Utilities::FileExists(filename))
       {
-       bbtkDebugMessage("Config",1, 
+                       bbtkDebugMessage("config",1, 
                         "* Creating [" << filename << "]" << std::endl);
-       // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
-       std::string doc_path = mInstall_path + "/" 
-         + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH) + "/";
-       Utilities::MakeValidFileName(doc_path); 
-       std::ofstream f;
-       f.open(filename.c_str(), std::ios::out );
-       f << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD "
-         << "HTML 4.01 Transitional//EN\">"
-         << "<html><head><title>Help Contents - bbtk "
-         << GetVersion() << "</title>"
-         << "<meta http-equiv=\"Content-Type\" content=\"text/html; "
-         << "charset=iso-8859-1\"></head><H1>Help Contents</H1>"
-         << "<a href=\"bbdoc/index-category.html#demo\" "
-         << "target=\"information\">Demos</a><br>"
-         << "<a href=\"bbdoc/index-category.html#example\" "
-         << "target=\"information\">Examples</a>"
-         << "<H2>Guides</H2>"
-         << "<a href=\""
-         << doc_path 
-         << "bbtkUsersGuide/bbtkUsersGuide.html"
-         << "\" target=\"information\">User's Guide</a><br>"
-         << "<a href=\""
-         << doc_path
-         << "bbtkPackageDevelopersGuide/bbtkPackageDevelopersGuide.html"
-         << "\" target=\"information\">Package Developer's Guide</a><br>"
-         << "<a href=\""
-         << doc_path
-         << "doxygen/bbtk/main.html"
-         << "\" target=\"information\">bbtk library doxygen doc</a><br>"
-         << "<H2>Boxes</H2>"
-         << "<a target=\"information\" href=\"bbdoc/index-alpha.html\">"
-         << "Alphabetical list</a><br>"
-         << "<a target=\"information\" href=\"bbdoc/index-package.html\">"
-         << "List by package</a><br>"
-         << "<a target=\"information\" href=\"bbdoc/index-category.html\">"
-         << "List by category</a><br>"
-         << "<a target=\"information\" href=\"bbdoc/index-adaptors.html\">"
-         << "List of adaptors</a><br>"
-         << "</body>"
-         << "</html>";
-      }
+                       // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
+                       std::string doc_path = mInstall_path + "/" 
+                         + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH) + "/";
+                       Utilities::MakeValidFileName(doc_path); 
+       
 
+                       std::ofstream f;
+                       f.open(filename.c_str(), std::ios::out );
+                       f << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD "
+                         << "HTML 4.01 Transitional//EN\">"
+                         << "<html><head><title>Help Contents - bbtk "
+                         << GetVersion() << "</title>"
+                         << "<meta http-equiv=\"Content-Type\" content=\"text/html; "
+                         << "charset=iso-8859-1\"></head><H1>Help Contents</H1>"
+                         << "<a href=\"bbdoc/index-category.html#demo\" "
+                         << "target=\"information\">Demos</a><br>"
+                         << "<a href=\"bbdoc/index-category.html#example\" "   
+                         << "target=\"information\">Examples</a>"
+                         << "<H2>Guides</H2>"
+                         << "<a href=\""
+                         << doc_path 
+                         << "bbtkUsersGuide/bbtkUsersGuide.pdf"
+                         << "\" target=\"information\">User's Guide</a><br>"
+                         << "<a href=\""
+                         << doc_path
+                         << "bbtkDevelopersGuide/bbtkDevelopersGuide.pdf"
+                         << "\" target=\"information\">Developer's Guide</a><br>"
+                         << "<a href=\""
+                         << doc_path
+                         << "bbtkPackageDevelopersGuide/bbtkPackageDevelopersGuide.pdf"
+                         << "\" target=\"information\">Package Developer's Guide</a><br>"
+                         << "<a href=\""
+                         << doc_path
+                         << "doxygen/bbtk/main.html"
+                         << "\" target=\"information\">bbtk library doxygen doc</a><br>"
+                         << "<H2>Boxes</H2>"
+                         << "<a target=\"information\" href=\"bbdoc/index-alpha.html\">"
+                         << "Alphabetical list</a><br>"
+                         << "<a target=\"information\" href=\"bbdoc/index-package.html\">"
+                         << "List by package</a><br>"
+                         << "<a target=\"information\" href=\"bbdoc/index-category.html\">"
+                         << "List by category</a><br>"
+                         << "<a target=\"information\" href=\"bbdoc/index-adaptors.html\">"
+                         << "List of adaptors</a><br>"
+                         << "</body>"
+                 << "</html>";
+      } // if
 
     mTemp_path = Utilities::MakeUserSettingsFullFileName("tmp");
     Utilities::CreateDirectoryIfNeeded(mTemp_path);
@@ -278,7 +302,7 @@ namespace bbtk
     FILE *fp;
     char configXml[250];
     sprintf (configXml , "%s/bbtk_config.xml", rootDirectory);
-    bbtkDebugMessage("Config",1, "in CreateConfigXML[" << configXml << "]" << std::endl);
+    bbtkDebugMessage("config",1, "in CreateConfigXML[" << configXml << "]" << std::endl);
     fp = fopen (configXml, "w");
     fprintf(fp, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
     fprintf(fp, "<config>\n");
@@ -391,7 +415,7 @@ namespace bbtk
     sprintf(copyFile,"copy %s\\bbtk_config.xml.tmp \"%s\"\\bbtk_config.xml ",bbtk_path,rootDirectory );
     
     int attribs = GetFileAttributes (rootDirectory);
-    bbtkMessage("Config",1,std::hex << attribs << " " << FILE_ATTRIBUTE_DIRECTORY << std::endl);
+    bbtkMessage("config",1,std::hex << attribs << " " << FILE_ATTRIBUTE_DIRECTORY << std::endl);
     if ( attribs != 0xFFFFFFFF)
       {
        if ((attribs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) /// \TODO : check !
@@ -427,7 +451,7 @@ namespace bbtk
   void ConfigurationFile::Read(const std::string& filename)
   {
     
-    bbtkDebugMessage("Config",1,"ConfigurationFile::Read(" <<filename << ")" << std::endl);
+    bbtkDebugMessage("config",1,"ConfigurationFile::Read(" <<filename << ")" << std::endl);
     
     mConfig_xml_full_path = filename;
     XMLResults* res = new XMLResults;
@@ -437,12 +461,12 @@ namespace bbtk
       {
        std::string mess = GetErrorMessage(res,filename);
        delete res;
-       bbtkDebugMessage("Config",1,mess<< std::endl);
+       bbtkDebugMessage("config",1,mess<< std::endl);
        bbtkError(mess);
       }
     delete res;
     
-    bbtkDebugMessage("Config",1,"OK" << std::endl);
+    bbtkDebugMessage("config",1,"OK" << std::endl);
   
     int i,j;
     
@@ -503,7 +527,7 @@ namespace bbtk
   //=========================================================================
   bool ConfigurationFile::AddPackagePathsAndWrite( const std::string& path )
   {
-    bbtkDebugMessageInc("Config",9,
+    bbtkDebugMessageInc("config",9,
                        "ConfigurationFile::AddPackagePathsAndWrite("
                        <<path<<")"<<std::endl);
     
@@ -516,7 +540,7 @@ namespace bbtk
       {
        std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
        delete res;
-       bbtkDebugMessage("Config",1,mess<< std::endl);
+       bbtkDebugMessage("config",1,mess<< std::endl);
        bbtkError(mess);
       }
    delete res;
@@ -564,7 +588,7 @@ namespace bbtk
     if ( err != eXMLErrorNone ) 
       {
        std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
-       bbtkDebugMessage("Config",1,mess<< std::endl);
+       bbtkDebugMessage("config",1,mess<< std::endl);
        bbtkError(mess);
       }
 
@@ -575,7 +599,7 @@ namespace bbtk
   //=========================================================================
   void ConfigurationFile::GetHelp(int level) const
   {
-    bbtkDebugMessageInc("Config",9,"ConfigurationFile::GetHelp("<<level
+    bbtkDebugMessageInc("config",9,"ConfigurationFile::GetHelp("<<level
                        <<")"<<std::endl);
     
     const std::string config_xml_full_path      = Get_config_xml_full_path();    
@@ -587,30 +611,30 @@ namespace bbtk
     const std::vector<std::string>bbs_paths     = Get_bbs_paths();
     const std::vector<std::string>package_paths = Get_package_paths();
     
-    bbtkMessage("Help",level, "============="   << std::endl);           
-    bbtkMessage("Help",level, "Configuration"   << std::endl);
-    bbtkMessage("Help",level, "============="   << std::endl);
-    bbtkMessage("Help",level, "bbtk_config.xml    : [" << config_xml_full_path  << "]" << std::endl); 
-    bbtkMessage("Help",level, "Documentation Path : [" << url             << "]" << std::endl);
-    bbtkMessage("Help",level, "Data Path          : [" << data_path       << "]" << std::endl);
-    bbtkMessage("Help",level, "Temp Directory     : [" << default_temp_dir << "]" << std::endl);
-    bbtkMessage("Help",level, "File Separator     : [" << file_separator  << "]" << std::endl);
+    bbtkMessage("help",level, "============="   << std::endl);           
+    bbtkMessage("help",level, "Configuration"   << std::endl);
+    bbtkMessage("help",level, "============="   << std::endl);
+    bbtkMessage("help",level, "bbtk_config.xml    : [" << config_xml_full_path  << "]" << std::endl); 
+    bbtkMessage("help",level, "Documentation Path : [" << url             << "]" << std::endl);
+    bbtkMessage("help",level, "Data Path          : [" << data_path       << "]" << std::endl);
+    bbtkMessage("help",level, "Temp Directory     : [" << default_temp_dir << "]" << std::endl);
+    bbtkMessage("help",level, "File Separator     : [" << file_separator  << "]" << std::endl);
 
     std::vector<std::string>::const_iterator i;
            
-    bbtkMessage("Help",level, "BBS Paths   " << std::endl);     
+    bbtkMessage("help",level, "BBS Paths   " << std::endl);     
     for (i = bbs_paths.begin(); i!=bbs_paths.end(); ++i )
     {
-      bbtkMessage("Help",level,"--- ["<<*i<<"]"<<std::endl);
+      bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl);
     }    
     
-    bbtkMessage("Help",level, "PACKAGE Paths : " << std::endl);     
+    bbtkMessage("help",level, "PACKAGE Paths : " << std::endl);     
     for (i = package_paths.begin(); i!=package_paths.end(); ++i )
     {
-      bbtkMessage("Help",level,"--- ["<<*i<<"]"<<std::endl);
+      bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl);
     }
 
-    bbtkDebugDecTab("Config",9);
+    bbtkDebugDecTab("config",9);
   }
   //=========================================================================