bbtkConfigurationFile.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkConfigurationFile.cxx,v $
00004   Language:  C++
00005   Date:      $Date: 2011/03/08 16:56:13 $
00006   Version:   $Revision: 1.37 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and
00015 *  abiding by the rules of distribution of free software. You can  use,
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability.
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */
00030 
00036 #include "bbtkConfigurationFile.h"
00037 #include "bbtkMessageManager.h"
00038 #include "bbtkXML.h"
00039 #include "bbtkUtilities.h"
00040 
00041 #include "creaSystem.h"
00042 
00043 #if defined(WIN32)
00044 # include <direct.h> // for getcwd
00045 # include <windows.h>
00046 #endif
00047 
00048 
00049 namespace bbtk
00050 {
00051   //====================================================================
00053   ConfigurationFile::ConfigurationFile()
00054   {
00055     mFile_separator = VALID_FILE_SEPARATOR;
00056 
00057     // ==> Set system paths
00058     mBin_path = Utilities::GetExecutablePath();
00059 
00060 /*      EED 23 Mars 2009
00061 #ifdef MACOSX
00062     mInstall_path = mBin_path + "/../../../..";
00063 #else
00064     mInstall_path = mBin_path + "/..";
00065 #endif
00066 */
00067 #ifdef MACOSX
00068           std::string macPath("Contents/MacOS");
00069           int sbp = mBin_path.length();
00070           int smp = macPath.length();
00071           if (mBin_path.compare( sbp-smp, smp, macPath )==0 )
00072           {
00073                   mBin_path = mBin_path + "/../../..";
00074           }
00075 #endif
00076 
00078           mInstall_path = mBin_path + "/..";
00079 
00080     // The relative path to the doc folder (=BBTK_DOC_REL_PATH)
00081     //    mDoc_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH);
00082     // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
00083     //    mDoc_path = mInstall_path + "/" + mDoc_rel_path;
00084     // Have to create bbtk user's dirs if needed
00085 
00086     // LG 27/01/09 : doc is now user dependent
00087     //               and located in user's .bbtk dir /doc
00088     // All dirs under .bbtk user's dir are set and created by:
00089     InitializeDotBbtkStructure();
00090 
00091     // The relative path to the doc folder (=BBTK_BBS_REL_PATH)
00092     mBbs_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_BBS_REL_PATH);
00093     // The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path)
00094     mBbs_path = mInstall_path + "/" + mBbs_rel_path;
00095 
00096     mData_path = mInstall_path + "/" + BBTK_STRINGIFY_SYMBOL(BBTK_DATA_REL_PATH);
00097 
00098     Utilities::replace( mBin_path,
00099                         INVALID_FILE_SEPARATOR,
00100                         VALID_FILE_SEPARATOR);
00101     Utilities::replace( mInstall_path,
00102                         INVALID_FILE_SEPARATOR,
00103                         VALID_FILE_SEPARATOR);
00104     Utilities::replace( mBbs_path,
00105                         INVALID_FILE_SEPARATOR,
00106                         VALID_FILE_SEPARATOR);
00107     Utilities::replace( mData_path,
00108                         INVALID_FILE_SEPARATOR,
00109                         VALID_FILE_SEPARATOR);
00110 
00111     bbtkMessage("config",1," ==> bin    : '"<<mBin_path<<"'"<<std::endl);
00112     bbtkMessage("config",1," ==> prefix : '"<<mInstall_path<<"'"<<std::endl);
00113     bbtkMessage("config",1," ==> doc    : '"<<mDoc_path<<"'"<<std::endl);
00114     bbtkMessage("config",1," ==> bbs    : '"<<mBbs_path<<"'"<<std::endl);
00115     bbtkMessage("config",1," ==> data   : '"<<mData_path<<"'"<<std::endl);
00116 
00117     // bbs_paths
00118     // always add "." (current working directory) at the begining
00119     mBbs_paths.push_back( "." );
00120     // add system bbs path
00121     mBbs_paths.push_back(mBbs_path);
00122     // add toolsbbtk/appli
00123 //EED    std::string toolsappli_rel_path(mFile_separator);
00124     std::string toolsappli_rel_path("/");
00125 //EED    toolsappli_rel_path +=  "toolsbbtk" + mFile_separator + "appli";
00126     toolsappli_rel_path +=  "toolsbbtk/appli";
00127     //
00128     //-----------------------------------------------------------
00129     // LG : REMOVE BUGGY PATH WITH include *:
00130     //
00131     //    mBbs_paths.push_back(mBbs_path + toolsappli_rel_path);
00132     //-----------------------------------------------------------
00133     int iStrVec,sizeStrVec;
00134 
00135     sizeStrVec = mBbs_paths.size();
00136     for (iStrVec=0;iStrVec<sizeStrVec;iStrVec++){
00137       Utilities::replace( mBbs_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00138     }
00139 
00140 
00141     // always add "." (current working directory) at the begining
00142     mPackage_paths.push_back(".");
00143     // add system bin path (for build tree / standalone folder install)
00144     mPackage_paths.push_back(mBin_path);
00145     // add system lib path (for install tree)
00146     //EED    mPackage_paths.push_back(mInstall_path + mFile_separator + "lib");
00147     
00148     //mPackage_paths.push_back(mInstall_path + "/lib"); // JPR
00149     //mPackage_paths.push_back(mInstall_path + "/lib64");// JPR
00150     
00152     
00153     mPackage_paths.push_back(mInstall_path + "/lib/creatools");
00154     mPackage_paths.push_back(mInstall_path + "/lib64/creatools");
00155 #ifdef WIN32
00156     // add bin/Debug bin/Release paths (for build/install tree)
00157     //EED    mPackage_paths.push_back(mBin_path + mFile_separator + "Debug");
00158     mPackage_paths.push_back(mBin_path + "/Debug");
00159     //EED    mPackage_paths.push_back(mBin_path + mFile_separator + "Release");
00160     mPackage_paths.push_back(mBin_path + "/Release");
00161 #endif
00162 
00163     sizeStrVec = mPackage_paths.size();
00164     for (iStrVec=0;iStrVec<sizeStrVec;iStrVec++){
00165       Utilities::replace( mPackage_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00166     }
00167 
00168     GetHelp(2);
00169 
00170     // ==> First we look for bbtk_config.xml in "."
00171     char buf[2048];
00172     const char *currentDir = getcwd(buf, 2048);
00173 
00174     if( !currentDir )
00175       {
00176         std::cerr << "Path was too long to fit on 2048 bytes ?!?" << std::endl;
00177         // \todo : what else?
00178         // How abort a constructor and warn the caller function?
00179         // LG : throw an exception
00180       }
00181 
00182     //    std::string configXmlFullPathName = currentDir + mFile_separator + "bbtk_config.xml";
00183     std::string configXmlFullPathName = currentDir ;
00184     configXmlFullPathName += "/bbtk_config.xml";
00185     Utilities::replace( configXmlFullPathName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00186 
00187     if ( Utilities::FileExists( configXmlFullPathName ))
00188       {
00189         bbtkMessage("config",1, "ConfigurationFile : [" << configXmlFullPathName <<
00190                     "] found in current directory" << std::endl);
00191         //Read(configXmlFullPathName.c_str());
00192         // traiter le fichier local
00193       }
00194 
00195     // ==> Then we look for bbtk_config.xml in ".bbtk"
00196     else
00197       {
00198         configXmlFullPathName = Utilities::MakeUserSettingsFullFileName("bbtk_config.xml");
00199         if (!Utilities::FileExists( configXmlFullPathName ))
00200           {
00201             // ==> Nothing found, we create bbtk_config.xml in ".bbtk"
00202             InstallPath ();
00203           }
00204       }
00205 
00206     // In any case, deal with bbtk_config.xml!
00207     Read(configXmlFullPathName.c_str());
00208   }
00209   //=========================================================================
00210 
00211   //=========================================================================
00213   ConfigurationFile::~ConfigurationFile()
00214   {
00215   }
00216   //=========================================================================
00217 
00218   //=========================================================================
00219   void ConfigurationFile::InitializeDotBbtkStructure()
00220   {
00221     mDot_bbtk_path = Utilities::GetUserSettingsDir();
00222     mDot_bbtk_is_new = false;
00223     if (!Utilities::FileExists(mDot_bbtk_path)) mDot_bbtk_is_new = true;
00224     Utilities::CreateDirectoryIfNeeded(mDot_bbtk_path);
00225 
00226     mDoc_path = Utilities::MakeUserSettingsFullFileName("doc");
00227     Utilities::CreateDirectoryIfNeeded(mDoc_path);
00228 
00229     std::string bbdoc_path =
00230       Utilities::MakeUserSettingsFullFileName("doc/bbdoc");
00231     Utilities::CreateDirectoryIfNeeded(bbdoc_path);
00232 
00233     // Create help_contents.html if does not exist
00234     std::string filename = Utilities::MakeUserSettingsFullFileName("doc/help_contents.html");
00235     if (!Utilities::FileExists(filename))
00236       {
00237                         bbtkDebugMessage("config",1,
00238                          "* Creating [" << filename << "]" << std::endl);
00239                         // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
00240                         std::string doc_path = mInstall_path + "/"
00241                           + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH) + "/";
00242                         Utilities::MakeValidFileName(doc_path);
00243 
00244                         std::ofstream f;
00245                         f.open(filename.c_str(), std::ios::out );
00246                         f << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD "
00247                           << "HTML 4.01 Transitional//EN\">"
00248                           << "<html><head><title>Help Contents - bbtk "
00249                           << GetVersion() << "</title>"
00250                           << "<meta http-equiv=\"Content-Type\" content=\"text/html; "
00251                           << "charset=iso-8859-1\"></head><H1>Help Contents</H1>"
00252                           << "<a href=\"bbdoc/index-category.html#demo\" "
00253                           << "target=\"information\">Demos</a><br>"
00254                           << "<a href=\"bbdoc/index-category.html#example\" "
00255                           << "target=\"information\">Examples</a>"
00256                           << "<H2>Guides</H2>"
00257                           << "<a href=\""
00258                           << doc_path
00259                           << "bbtkUsersGuide/bbtkUsersGuide.pdf"
00260                           << "\" target=\"information\">User's Guide</a><br>"
00261                           << "<a href=\""
00262                           << doc_path
00263                           << "bbtkDevelopersGuide/bbtkDevelopersGuide.pdf"
00264                           << "\" target=\"information\">Developer's Guide</a><br>"
00265                           << "<a href=\""
00266                           << doc_path
00267                           << "bbtkPackageDevelopersGuide/bbtkPackageDevelopersGuide.pdf"
00268                           << "\" target=\"information\">Package Developer's Guide</a><br>"
00269                           << "<a href=\""
00270                           << doc_path
00271                           << "doxygen/bbtk/main.html"
00272                           << "\" target=\"information\">bbtk library doxygen doc</a><br>"
00273                           << "<H2>Boxes</H2>"
00274                           << "<a target=\"information\" href=\"bbdoc/index-alpha.html\">"
00275                           << "Alphabetical list</a><br>"
00276                           << "<a target=\"information\" href=\"bbdoc/index-package.html\">"
00277                           << "List by package</a><br>"
00278                           << "<a target=\"information\" href=\"bbdoc/index-category.html\">"
00279                           << "List by category</a><br>"
00280                           << "<a target=\"information\" href=\"bbdoc/index-adaptors.html\">"
00281                           << "List of adaptors</a><br>"
00282                           << "</body>"
00283                   << "</html>";
00284       } // if
00285 
00286     mTemp_path = Utilities::MakeUserSettingsFullFileName("tmp");
00287     Utilities::CreateDirectoryIfNeeded(mTemp_path);
00288 
00289   }
00290   //=========================================================================
00291 
00292   //=========================================================================
00293   void ConfigurationFile::CreateConfigXML( char *rootDirectory )
00294   {
00295     FILE *fp;
00296     char configXml[250];
00297     sprintf (configXml , "%s/bbtk_config.xml", rootDirectory);
00298     bbtkDebugMessage("config",1, "in CreateConfigXML[" << configXml << "]" << std::endl);
00299     fp = fopen (configXml, "w");
00300     fprintf(fp, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
00301     fprintf(fp, "<config>\n");
00302     fprintf(fp, "   <bbs_path>     </bbs_path>\n");
00303     fprintf(fp, "   <package_path> </package_path>\n");
00304     fprintf(fp, "</config>\n");
00305     fclose(fp);
00306   }
00307   //=========================================================================
00308 
00309 
00310 
00311 
00312   //=========================================================================
00313   void ConfigurationFile::InstallPath ()
00314   {
00315 
00316     /*--------------------------------------------------
00317       New policy for bbtk_config.xml :
00318 
00319       if bbtk_config.xml found in current directory (user is an aware user!)
00320       use it!
00321 
00322       else if bbtk_config.xml found in HOME/.bbtk (user already worked with it)
00323       use it!
00324 
00325       else if bbtk_config.xml.tmp found in /usr/local/bin or c:\\Program Files\\BBTK\\bin
00326       copy it as .bbtk/bbtk_config.xml
00327 
00328       else (nothing installed)
00329       create a minimum version in HOME/.bbtk
00330       ----------------------------------------------------*/
00331 
00332 
00333     // -----------------------------------------------------------------
00334 #if defined(__GNUC__)
00335 
00336     // ------------------ create some usefull strings ----------------
00337     // installed bbtk_path
00338     char bbtk_path[1000];
00339     strcpy(bbtk_path, Utilities::GetExecutablePath().c_str());  // JPR
00340     //strcpy(bbtk_path, "/usr/local/bin");
00341 
00342     // rootDirectory
00343     char rootDirectory[200];
00344     sprintf( rootDirectory,  "%s/.bbtk", getenv("HOME"));
00345 
00346     // configPath
00347     char configPath[200];
00348     sprintf(configPath, "%s/bbtk_config.xml",rootDirectory);
00349 
00350     // configXmlTmp
00351     char configXmlTmp[250];
00352     sprintf(configXmlTmp, "%s/bbtk_config.xml.tmp", bbtk_path);
00353 
00354     // copyFile
00355     char copyFile[250];
00356 
00357     if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found (not installed)
00358       {
00359         // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk
00360         CreateConfigXML( rootDirectory );// create .bbtk
00361       }
00362     else
00363       {
00364         sprintf(copyFile,"cp %s  %s/bbtk_config.xml ",configXmlTmp,rootDirectory );
00365         if (!Utilities::FileExists(configPath))
00366           {
00367             system(copyFile);
00368           }
00369       }
00370     return;
00371 
00372     // ------------------------------------------------------------------
00373 #elif defined(WIN32)
00374 
00375 
00376     // installed bbtk_path
00377     char bbtk_path[100];
00378     strcpy(bbtk_path, "\"c:\\Program Files\\BBTK\\bin\"");
00379     char bbtk_path2[100];
00380     strcpy(bbtk_path2, "c:\\Program Files\\BBTK\\bin");
00381 
00382     // rootDirectory
00383     char rootDirectory[200];
00384     sprintf(rootDirectory, "%s\\.bbtk",getenv("USERPROFILE"));
00385     //  std::cout << "[" << rootDirectory << "]" << std::endl;
00386 
00387     // configPath
00388     char configPath[200];
00389     sprintf(configPath, "%s\\bbtk_config.xml",rootDirectory);
00390 
00391     // makeDir
00392     char makeDir[250];
00393     sprintf( makeDir, "mkdir \"%s\" ", rootDirectory);
00394 
00395     // configXmlTmp
00396     char configXmlTmp[250];
00397     sprintf(configXmlTmp, "%s\\bbtk_config.xml.tmp", bbtk_path2);
00398 
00399     // copyFile
00400     char copyFile[250];
00401 
00402     if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found
00403       {
00404         // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk
00405         CreateConfigXML( rootDirectory );// create .bbtk
00406         return;
00407       }
00408 
00409     sprintf(copyFile,"copy %s\\bbtk_config.xml.tmp \"%s\"\\bbtk_config.xml ",bbtk_path,rootDirectory );
00410 
00411     int attribs = GetFileAttributes (rootDirectory);
00412     bbtkMessage("config",1,std::hex << attribs << " " << FILE_ATTRIBUTE_DIRECTORY << std::endl);
00413     if ( attribs != 0xFFFFFFFF)
00414       {
00415         if ((attribs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) 
00416           {
00417             if ( GetFileAttributes( configPath ) == 0xFFFFFFFF)
00418               {
00419                 system(copyFile);
00420               }
00421           }
00422       }
00423     else
00424       {
00425         system(makeDir);
00426         system(copyFile);
00427       }
00428     return;
00429     // ------------------------------------------------------------------
00430 #else
00432 
00433   return;
00434 #endif
00435 
00436 }
00437   //=========================================================================
00438 
00439 
00440 
00441   //=========================================================================
00442   // Gets the list of directories holding bb scripts, packages, dll, ... from the xml file
00443   //      bbtk_config.xml
00444 
00445   void ConfigurationFile::Read(const std::string& filename)
00446   {
00447 
00448     bbtkDebugMessage("config",1,"ConfigurationFile::Read(" <<filename << ")" << std::endl);
00449 
00450     mConfig_xml_full_path = filename;
00451     XMLResults* res = new XMLResults;
00452     XMLNode BB = XMLNode::parseFile((XMLCSTR)filename.c_str(),(XMLCSTR)"config",res);
00453 
00454     if ( res->error != eXMLErrorNone )
00455       {
00456         std::string mess = GetErrorMessage(res,filename);
00457         delete res;
00458         bbtkDebugMessage("config",1,mess<< std::endl);
00459         bbtkError(mess);
00460       }
00461     delete res;
00462 
00463     bbtkDebugMessage("config",1,"OK" << std::endl);
00464 
00465     int i,j;
00466 
00467     // Description
00468     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"description"); i++)
00469       {
00470         std::string val;
00471         GetTextOrClear(BB.getChildNode((XMLCSTR)"description",&j),val);
00472         mDescription += val;
00473       }
00474 
00475     // Url
00476     if( BB.nChildNode((XMLCSTR)"url") )
00477       GetTextOrClear(BB.getChildNode((XMLCSTR)"url"),mUrl);
00478 
00479     // Data_Path
00480     if( BB.nChildNode((XMLCSTR)"data_path") )
00481       GetTextOrClear(BB.getChildNode((XMLCSTR)"data_path"),mData_path);
00482 
00483     // install_path
00484     //  if( BB.nChildNode((XMLCSTR)"install_path") )
00485     //   GetTextOrClear(BB.getChildNode((XMLCSTR)"install_path"),mInstall_path);
00486 
00487     // add user bbs paths
00488     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"bbs_path"); i++)
00489       {
00490         std::string val;
00491         GetTextOrClear(BB.getChildNode((XMLCSTR)"bbs_path",&j),val);
00492         mBbs_paths.push_back(val);
00493       }
00494 
00495     // package_paths
00496 
00497     // add user package path
00498     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"package_path"); i++)
00499       {
00500         std::string val;
00501         GetTextOrClear(BB.getChildNode((XMLCSTR)"package_path",&j),val);
00502         mPackage_paths.push_back(val);
00503       }
00504 
00505     // default_temp_dir
00506     /*
00507     if( BB.nChildNode((XMLCSTR)"default_temp_dir") )
00508       GetTextOrClear(BB.getChildNode((XMLCSTR)"default_temp_dir"),mDefault_temp_dir);
00509 
00510     if ( mDefault_temp_dir == "$") // no value found in config_xml
00511       {
00512         size_t pos = mConfig_xml_full_path.find("bbtk_config.xml");
00513         mDefault_temp_dir = mConfig_xml_full_path.substr (0,pos);
00514       }
00515     */
00516 
00517     GetHelp(2);
00518   }
00519   //=========================================================================
00520 
00521   //=========================================================================
00522   bool ConfigurationFile::AddPackagePathsAndWrite( const std::string& path )
00523   {
00524     bbtkDebugMessageInc("config",9,
00525                         "ConfigurationFile::AddPackagePathsAndWrite("
00526                         <<path<<")"<<std::endl);
00527 
00528      XMLResults* res = new XMLResults;
00529     XMLNode BB =
00530       XMLNode::parseFile((XMLCSTR)Get_config_xml_full_path().c_str(),
00531                          (XMLCSTR)"config",res);
00532 
00533     if ( res->error != eXMLErrorNone )
00534       {
00535         std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
00536         delete res;
00537         bbtkDebugMessage("config",1,mess<< std::endl);
00538         bbtkError(mess);
00539       }
00540    delete res;
00541 
00542 #ifdef _WIN32
00543     std::string bbs_path = path + "/bbs";
00544 #else
00545     std::string bbs_path = path + "/share/bbtk/bbs" ;
00546 #endif
00547     XMLNode BBSPATH = BB.addChild((XMLCSTR)"bbs_path");
00548     BBSPATH.addText((XMLCSTR)bbs_path.c_str());
00549     Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
00550     mBbs_paths.push_back(bbs_path);
00551 
00552 #ifdef _WIN32
00553     std::string pack_path = path + "/bin";
00554 #else
00555     std::string pack_path = path ;
00556 #endif
00557     XMLNode PACKPATH = BB.addChild((XMLCSTR)"package_path");
00558     PACKPATH.addText((XMLCSTR)pack_path.c_str());
00559     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
00560     mPackage_paths.push_back(pack_path);
00561 
00562 #ifdef _WIN32
00563     pack_path = path + "/RelWithDebInfo";
00564     PACKPATH = BB.addChild((XMLCSTR)"package_path");
00565     PACKPATH.addText((XMLCSTR)pack_path.c_str());
00566     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
00567     mPackage_paths.push_back(pack_path);
00568     pack_path = path + "/Debug";
00569     PACKPATH = BB.addChild((XMLCSTR)"package_path");
00570     PACKPATH.addText((XMLCSTR)pack_path.c_str());
00571     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
00572     mPackage_paths.push_back(pack_path);
00573     pack_path = path + "/Release";
00574     PACKPATH = BB.addChild((XMLCSTR)"package_path");
00575     PACKPATH.addText((XMLCSTR)pack_path.c_str());
00576     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
00577     mPackage_paths.push_back(pack_path);
00578 #endif
00579 
00580 
00581     XMLError err = BB.writeToFile((XMLCSTR)Get_config_xml_full_path().c_str());
00582     if ( err != eXMLErrorNone )
00583       {
00584         std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
00585         bbtkDebugMessage("config",1,mess<< std::endl);
00586         bbtkError(mess);
00587       }
00588 
00589     return true;
00590   }
00591   //=========================================================================
00592 
00593   //=========================================================================
00594   void ConfigurationFile::GetHelp(int level) const
00595   {
00596     bbtkDebugMessageInc("config",9,"ConfigurationFile::GetHelp("<<level
00597                         <<")"<<std::endl);
00598 
00599     const std::string config_xml_full_path      = Get_config_xml_full_path();
00600     const std::string description               = Get_description();
00601     const std::string url                       = Get_doc_path();
00602     const std::string data_path                 = Get_data_path();
00603     const std::string default_temp_dir          = Get_default_temp_dir();
00604     const std::string file_separator            = Get_file_separator();
00605     const std::vector<std::string>bbs_paths     = Get_bbs_paths();
00606     const std::vector<std::string>package_paths = Get_package_paths();
00607 
00608     bbtkMessage("help",level, "============="   << std::endl);
00609     bbtkMessage("help",level, "Configuration"   << std::endl);
00610     bbtkMessage("help",level, "============="   << std::endl);
00611     bbtkMessage("help",level, "bbtk_config.xml    : [" << config_xml_full_path  << "]" << std::endl);
00612     bbtkMessage("help",level, "Documentation Path : [" << url             << "]" << std::endl);
00613     bbtkMessage("help",level, "Data Path          : [" << data_path       << "]" << std::endl);
00614     bbtkMessage("help",level, "Temp Directory     : [" << default_temp_dir << "]" << std::endl);
00615     bbtkMessage("help",level, "File Separator     : [" << file_separator  << "]" << std::endl);
00616 
00617     std::vector<std::string>::const_iterator i;
00618 
00619     bbtkMessage("help",level, "BBS Paths   " << std::endl);
00620     for (i = bbs_paths.begin(); i!=bbs_paths.end(); ++i )
00621     {
00622       bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl);
00623     }
00624 
00625     bbtkMessage("help",level, "PACKAGE Paths : " << std::endl);
00626     for (i = package_paths.begin(); i!=package_paths.end(); ++i )
00627     {
00628       bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl);
00629     }
00630 
00631     bbtkDebugDecTab("config",9);
00632   }
00633   //=========================================================================
00634 
00635 
00636 } // namespace bbtk

Generated on Thu May 31 14:12:03 2012 for BBTK by  doxygen 1.5.7.1