bbtk::ConfigurationFile Class Reference

DDD. More...

#include <bbtkConfigurationFile.h>

List of all members.

Public Member Functions

 ~ConfigurationFile ()
 Destructor.
void GetHelp (int level) const
const std::string & Get_description () const
const std::string & Get_data_path () const
const std::string & Get_file_separator () const
const std::string & Get_bin_path () const
const std::string & Get_install_path () const
const std::string & Get_doc_path () const
const std::string & Get_rsc_path () const
const std::string & Get_root_bbs_path () const
const std::vector< std::string > & Get_bbs_paths () const
const std::vector< std::string > & Get_package_paths () const
const std::string & Get_config_xml_full_path () const
const std::string & Get_default_temp_dir () const
bool AddPackagePathsAndWrite (const std::string &package_root_path)

Static Public Member Functions

static ConfigurationFileGetInstance ()

Private Member Functions

 ConfigurationFile ()
 Constructor.
void InstallPath ()
void Read (const std::string &fileName)
std::string GetExecutablePath ()
void CreateConfigXML (char *rootDirectory)

Private Attributes

std::string mDescription
std::string mConfig_xml_full_path
 Where is the file bbtk_config.xml.
std::string mBin_path
std::string mInstall_path
 The path to the install prefix (=mBinPath+"/..").
std::string mDoc_rel_path
 The relative path to the doc folder (=BBTK_DOC_REL_PATH).
std::string mDoc_path
 The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path).
std::string mBbs_rel_path
 The relative path to the doc folder (=BBTK_BBS_REL_PATH).
std::string mBbs_path
 The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path).
std::string mRsc_rel_path
 The relative path to the rsc folder (=BBTK_RSC_REL_PATH).
std::string mRsc_path
 The path to the rsc folder (=mInstall_path+"/"+mRsc_rel_path).
std::string mData_path
std::string mFile_separator
 / or \, depending on the OS
std::string mUrl
std::vector< std::string > mBbs_paths
 Scripts.
std::vector< std::string > mPackage_paths
 Package dlls.
std::vector< std::string > mExt_dll_paths
 If Packages link against extern dlls.
std::string mDefault_temp_dir
 Temp directory for generated data.


Detailed Description

DDD.

Definition at line 73 of file bbtkConfigurationFile.h.


Constructor & Destructor Documentation

bbtk::ConfigurationFile::~ConfigurationFile (  ) 

Destructor.

Definition at line 188 of file bbtkConfigurationFile.cxx.

00189   {
00190   }

bbtk::ConfigurationFile::ConfigurationFile (  )  [private]

Constructor.

Definition at line 52 of file bbtkConfigurationFile.cxx.

References BBTK_STRINGIFY_SYMBOL, bbtkMessage, GetExecutablePath(), GetHelp(), InstallPath(), INVALID_FILE_SEPARATOR, mBbs_path, mBbs_paths, mBbs_rel_path, mBin_path, mData_path, mDoc_path, mDoc_rel_path, mFile_separator, mInstall_path, mPackage_paths, Read(), and VALID_FILE_SEPARATOR.

00053   {
00054 
00055         mFile_separator = VALID_FILE_SEPARATOR;
00056     
00057     // ==> Set system paths 
00058     mBin_path = GetExecutablePath();
00059 //EED    mInstall_path = mBin_path + mFile_separator + "..";
00060     mInstall_path = mBin_path + "/..";
00061     // The relative path to the doc folder (=BBTK_DOC_REL_PATH)
00062     mDoc_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH);
00063     // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
00064 //EED    mDoc_path = mInstall_path + mFile_separator + mDoc_rel_path;
00065     mDoc_path = mInstall_path + "/" + mDoc_rel_path;
00066     // The relative path to the doc folder (=BBTK_BBS_REL_PATH)
00067     mBbs_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_BBS_REL_PATH);
00068     // The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path)
00069 //EED    mBbs_path = mInstall_path + mFile_separator + mBbs_rel_path;
00070     mBbs_path = mInstall_path + "/" + mBbs_rel_path;
00071     // The relative path to the rsc folder (=BBTK_RSC_REL_PATH)
00072     //   mRsc_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_RSC_REL_PATH);
00073     // The path to the rsc folder (=mInstall_path+"/"+mRsc_rel_path)
00074     //   mRsc_path = mInstall_path + mFile_separator + mRsc_rel_path;
00075     // The path to the bbtk data folder 
00076     // Initialized to mInstall_path+"/"+BBTK_DATA_REL_PATH
00077     // But can be overriden by value read from bbtk_config.xml
00078 //EED    mData_path = mInstall_path + mFile_separator + BBTK_STRINGIFY_SYMBOL(BBTK_DATA_REL_PATH);
00079     mData_path = mInstall_path + "/" + BBTK_STRINGIFY_SYMBOL(BBTK_DATA_REL_PATH);
00080 
00081         Utilities::replace( mBin_path           , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00082         Utilities::replace( mInstall_path       , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00083         Utilities::replace( mDoc_rel_path       , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00084         Utilities::replace( mDoc_path           , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00085         Utilities::replace( mBbs_path           , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00086         Utilities::replace( mData_path          , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00087 
00088     bbtkMessage("Config",1," ==> bin    : '"<<mBin_path<<"'"<<std::endl);
00089     bbtkMessage("Config",1," ==> prefix : '"<<mInstall_path<<"'"<<std::endl);
00090     bbtkMessage("Config",1," ==> doc    : '"<<mDoc_path<<"'"<<std::endl);
00091     bbtkMessage("Config",1," ==> bbs    : '"<<mBbs_path<<"'"<<std::endl);
00092     bbtkMessage("Config",1," ==> data   : '"<<mData_path<<"'"<<std::endl);
00093 
00094 
00095 
00096     
00097     // bbs_paths
00098     // always add "." (current working directory) at the begining
00099         mBbs_paths.push_back( "." ); 
00100     // add system bbs path 
00101     mBbs_paths.push_back(mBbs_path);
00102     // add toolsbbtk/appli 
00103 //EED    std::string toolsappli_rel_path(mFile_separator);
00104     std::string toolsappli_rel_path("/");
00105 //EED    toolsappli_rel_path +=  "toolsbbtk" + mFile_separator + "appli";
00106     toolsappli_rel_path +=  "toolsbbtk/appli";
00107     //
00108     //-----------------------------------------------------------
00109     // LG : REMOVE BUGGY PATH WITH include *:
00110     // 
00111     //    mBbs_paths.push_back(mBbs_path + toolsappli_rel_path);
00112     //-----------------------------------------------------------
00113     int iStrVec,sizeStrVec;
00114     
00115     sizeStrVec = mBbs_paths.size();
00116     for (iStrVec=0;iStrVec<sizeStrVec;iStrVec++){
00117       Utilities::replace( mBbs_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00118     }
00119 
00120     
00121     // always add "." (current working directory) at the begining
00122     mPackage_paths.push_back(".");   
00123     // add system bin path (for build tree / standalone folder install)
00124     mPackage_paths.push_back(mBin_path);
00125     // add system lib path (for install tree)
00126 //EED    mPackage_paths.push_back(mInstall_path + mFile_separator + "lib");
00127     mPackage_paths.push_back(mInstall_path + "/lib");
00128 #ifdef WIN32
00129     // add bin/Debug bin/Release paths (for build/install tree)
00130 //EED    mPackage_paths.push_back(mBin_path + mFile_separator + "Debug");
00131     mPackage_paths.push_back(mBin_path + "/Debug");
00132 //EED    mPackage_paths.push_back(mBin_path + mFile_separator + "Release");
00133     mPackage_paths.push_back(mBin_path + "/Release");
00134 #endif
00135 
00136         sizeStrVec = mPackage_paths.size();
00137         for (iStrVec=0;iStrVec<sizeStrVec;iStrVec++){
00138                 Utilities::replace( mPackage_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00139         }
00140 
00141 
00142 
00143     GetHelp(2);
00144    
00145     // ==> First we look for bbtk_config.xml in "."
00146     char buf[2048];
00147     const char *currentDir = getcwd(buf, 2048);
00148     
00149     if( !currentDir )
00150       {
00151         std::cerr << "Path was too long to fit on 2048 bytes ?!?" << std::endl;
00152         // \todo : what else?
00153         // How abort a constructor and warn the caller function?
00154         // LG : throw an exception 
00155       }
00156     
00157 //    std::string configXmlFullPathName = currentDir + mFile_separator + "bbtk_config.xml";
00158     std::string configXmlFullPathName = currentDir ;
00159                 configXmlFullPathName += "/bbtk_config.xml";
00160         Utilities::replace( configXmlFullPathName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
00161 
00162     if ( Utilities::FileExists( configXmlFullPathName ))
00163       {
00164         bbtkMessage("Config",1, "ConfigurationFile : [" << configXmlFullPathName << 
00165                     "] found in current directory" << std::endl); 
00166         //Read(configXmlFullPathName.c_str());
00167         // traiter le fichier local     
00168       }
00169     
00170     // ==> Then we look for bbtk_config.xml in ".bbtk"
00171     else 
00172       {
00173         configXmlFullPathName = Utilities::MakeUserSettingsFullFileName("bbtk_config.xml");
00174         if (!Utilities::FileExists( configXmlFullPathName ))
00175           {         
00176             // ==> Nothing found, we create bbtk_config.xml in ".bbtk"
00177             InstallPath ();
00178           }
00179       }
00180     
00181     // In any case, deal with bbtk_config.xml!
00182     Read(configXmlFullPathName.c_str());
00183   }

Here is the call graph for this function:


Member Function Documentation

static ConfigurationFile& bbtk::ConfigurationFile::GetInstance (  )  [inline, static]

Definition at line 77 of file bbtkConfigurationFile.h.

00078     {
00079       static ConfigurationFile f;
00080       return f;
00081     }

void bbtk::ConfigurationFile::InstallPath (  )  [private]

Todo:
ConfigurationFile::InstallPath() : exit when for not WIN32 and not__GNUC__

Definition at line 250 of file bbtkConfigurationFile.cxx.

References bbtkMessage, and CreateConfigXML().

Referenced by ConfigurationFile().

00251   {
00252     
00253     /*--------------------------------------------------
00254       New policy for bbtk_config.xml :
00255       
00256       if bbtk_config.xml found in current directory (user is an aware user!)
00257       use it!
00258       
00259       else if bbtk_config.xml found in HOME/.bbtk (user already worked with it)
00260       use it!
00261       
00262       else if bbtk_config.xml.tmp found in /usr/local/bin or c:\\Program Files\\BBTK\\bin
00263       copy it as .bbtk/bbtk_config.xml
00264       
00265       else (nothing installed)
00266       create a minimum version in HOME/.bbtk
00267       ----------------------------------------------------*/
00268     
00269     
00270     // -----------------------------------------------------------------
00271 #if defined(__GNUC__)
00272     
00273     // ------------------ create some usefull strings ----------------
00274     // installed bbtk_path
00275     char bbtk_path[100];
00276     strcpy(bbtk_path, "/usr/local/bin");
00277     
00278     // rootDirectory
00279     char rootDirectory[200];
00280     sprintf( rootDirectory,  "%s/.bbtk", getenv("HOME"));
00281     
00282     // configPath
00283     char configPath[200];
00284     sprintf(configPath, "%s/bbtk_config.xml",rootDirectory);
00285     
00286     // makeDir
00287     char makeDir[250];
00288     sprintf( makeDir, "mkdir \"%s\" ", rootDirectory);
00289     
00290     // configXmlTmp
00291     char configXmlTmp[250]; 
00292     sprintf(configXmlTmp, "%s/bbtk_config.xml.tmp", bbtk_path);
00293     
00294     // copyFile
00295     char copyFile[250];
00296     
00297     if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found (not installed)
00298       {  
00299         if (!Utilities::FileExists(rootDirectory)) // .bbtk not found
00300           {
00301             system(makeDir);  // create .bbtk
00302           }
00303         
00304         // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk
00305         CreateConfigXML( rootDirectory );// create .bbtk
00306       }
00307     else
00308       {
00309         sprintf(copyFile,"cp %s  %s/bbtk_config.xml ",configXmlTmp,rootDirectory );
00310         if (!Utilities::FileExists(rootDirectory))
00311           {
00312             //std::cout << "makeDir[" << makeDir << "]" << std::endl;
00313             system(makeDir);
00314           }
00315         
00316         if (!Utilities::FileExists(configPath))
00317           {
00318             system(copyFile);
00319           }
00320       }
00321     return;
00322     
00323     // ------------------------------------------------------------------
00324 #elif defined(WIN32)
00325     
00326     
00327     // installed bbtk_path
00328     char bbtk_path[100];
00329     strcpy(bbtk_path, "\"c:\\Program Files\\BBTK\\bin\"");
00330     char bbtk_path2[100];
00331     strcpy(bbtk_path2, "c:\\Program Files\\BBTK\\bin");
00332     
00333     // rootDirectory
00334     char rootDirectory[200];  
00335     sprintf(rootDirectory, "%s\\.bbtk",getenv("USERPROFILE"));
00336     //  std::cout << "[" << rootDirectory << "]" << std::endl;
00337     
00338     // configPath
00339     char configPath[200];
00340     sprintf(configPath, "%s\\bbtk_config.xml",rootDirectory);
00341     
00342     // makeDir
00343     char makeDir[250];
00344     sprintf( makeDir, "mkdir \"%s\" ", rootDirectory);
00345     
00346     // configXmlTmp
00347     char configXmlTmp[250]; 
00348     sprintf(configXmlTmp, "%s\\bbtk_config.xml.tmp", bbtk_path2);
00349     
00350     // copyFile
00351     char copyFile[250];
00352     
00353     if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found
00354       {
00355         if (!Utilities::FileExists(rootDirectory)) // .bbtk not found
00356           {
00357             system(makeDir);  // create .bbtk
00358           }
00359         
00360         // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk
00361         CreateConfigXML( rootDirectory );// create .bbtk
00362         return;
00363       }  
00364     
00365     sprintf(copyFile,"copy %s\\bbtk_config.xml.tmp \"%s\"\\bbtk_config.xml ",bbtk_path,rootDirectory );
00366     
00367     int attribs = GetFileAttributes (rootDirectory);
00368     bbtkMessage("Config",1,std::hex << attribs << " " << FILE_ATTRIBUTE_DIRECTORY << std::endl);
00369     if ( attribs != 0xFFFFFFFF)
00370       {
00371         if ((attribs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) 
00372           {
00373             if ( GetFileAttributes( configPath ) == 0xFFFFFFFF)
00374               {
00375                 system(copyFile);  
00376               } 
00377           }
00378       } 
00379     else 
00380       {
00381         system(makeDir);
00382         system(copyFile); 
00383       }    
00384     return;  
00385     // ------------------------------------------------------------------    
00386 #else
00388 
00389   return;    
00390 #endif
00391 
00392 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::ConfigurationFile::GetHelp ( int  level  )  const

Definition at line 543 of file bbtkConfigurationFile.cxx.

References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkMessage, Get_bbs_paths(), Get_config_xml_full_path(), Get_data_path(), Get_default_temp_dir(), Get_description(), Get_doc_path(), Get_file_separator(), Get_package_paths(), and bbtk::i.

Referenced by ConfigurationFile(), and Read().

00544   {
00545     bbtkDebugMessageInc("Config",9,"ConfigurationFile::GetHelp("<<level
00546                         <<")"<<std::endl);
00547     
00548     const std::string config_xml_full_path      = Get_config_xml_full_path();    
00549     const std::string description               = Get_description();
00550     const std::string url                       = Get_doc_path();
00551     const std::string data_path                 = Get_data_path();
00552     const std::string default_temp_dir          = Get_default_temp_dir();    
00553     const std::string file_separator            = Get_file_separator();    
00554     const std::vector<std::string>bbs_paths     = Get_bbs_paths();
00555     const std::vector<std::string>package_paths = Get_package_paths();
00556     
00557     bbtkMessage("Help",level, "============="   << std::endl);           
00558     bbtkMessage("Help",level, "Configuration"   << std::endl);
00559     bbtkMessage("Help",level, "============="   << std::endl);
00560     bbtkMessage("Help",level, "bbtk_config.xml    : [" << config_xml_full_path  << "]" << std::endl); 
00561     bbtkMessage("Help",level, "Documentation Path : [" << url             << "]" << std::endl);
00562     bbtkMessage("Help",level, "Data Path          : [" << data_path       << "]" << std::endl);
00563     bbtkMessage("Help",level, "Temp Directory     : [" << default_temp_dir << "]" << std::endl);
00564     bbtkMessage("Help",level, "File Separator     : [" << file_separator  << "]" << std::endl);
00565 
00566     std::vector<std::string>::const_iterator i;
00567            
00568     bbtkMessage("Help",level, "BBS Paths   " << std::endl);     
00569     for (i = bbs_paths.begin(); i!=bbs_paths.end(); ++i )
00570     {
00571       bbtkMessage("Help",level,"--- ["<<*i<<"]"<<std::endl);
00572     }    
00573     
00574     bbtkMessage("Help",level, "PACKAGE Paths : " << std::endl);     
00575     for (i = package_paths.begin(); i!=package_paths.end(); ++i )
00576     {
00577       bbtkMessage("Help",level,"--- ["<<*i<<"]"<<std::endl);
00578     }
00579 
00580     bbtkDebugDecTab("Config",9);
00581   }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& bbtk::ConfigurationFile::Get_description (  )  const [inline]

Definition at line 92 of file bbtkConfigurationFile.h.

Referenced by GetHelp().

00093     { return mDescription;}

Here is the caller graph for this function:

const std::string& bbtk::ConfigurationFile::Get_data_path (  )  const [inline]

Definition at line 96 of file bbtkConfigurationFile.h.

Referenced by GetHelp().

00097     { return mData_path;}  

Here is the caller graph for this function:

const std::string& bbtk::ConfigurationFile::Get_file_separator (  )  const [inline]

Definition at line 98 of file bbtkConfigurationFile.h.

Referenced by GetHelp().

00099         { return mFile_separator;}

Here is the caller graph for this function:

const std::string& bbtk::ConfigurationFile::Get_bin_path (  )  const [inline]

Definition at line 101 of file bbtkConfigurationFile.h.

00102     { return mBin_path;}

const std::string& bbtk::ConfigurationFile::Get_install_path (  )  const [inline]

Definition at line 103 of file bbtkConfigurationFile.h.

00104     { return mInstall_path;}

const std::string& bbtk::ConfigurationFile::Get_doc_path (  )  const [inline]

Definition at line 105 of file bbtkConfigurationFile.h.

Referenced by GetHelp().

00106     { return mDoc_path;}

Here is the caller graph for this function:

const std::string& bbtk::ConfigurationFile::Get_rsc_path (  )  const [inline]

Definition at line 107 of file bbtkConfigurationFile.h.

00108     { return mRsc_path;}

const std::string& bbtk::ConfigurationFile::Get_root_bbs_path (  )  const [inline]

Definition at line 110 of file bbtkConfigurationFile.h.

00111     { return mBbs_path;}

const std::vector<std::string>& bbtk::ConfigurationFile::Get_bbs_paths (  )  const [inline]

Definition at line 112 of file bbtkConfigurationFile.h.

Referenced by GetHelp().

00113     { return mBbs_paths;}

Here is the caller graph for this function:

const std::vector<std::string>& bbtk::ConfigurationFile::Get_package_paths (  )  const [inline]

Definition at line 114 of file bbtkConfigurationFile.h.

Referenced by GetHelp().

00115     { return mPackage_paths;}

Here is the caller graph for this function:

const std::string& bbtk::ConfigurationFile::Get_config_xml_full_path (  )  const [inline]

Definition at line 116 of file bbtkConfigurationFile.h.

Referenced by AddPackagePathsAndWrite(), and GetHelp().

00117     { return mConfig_xml_full_path;}

Here is the caller graph for this function:

const std::string& bbtk::ConfigurationFile::Get_default_temp_dir (  )  const [inline]

Definition at line 118 of file bbtkConfigurationFile.h.

Referenced by GetHelp().

00119     { return mDefault_temp_dir;}

Here is the caller graph for this function:

bool bbtk::ConfigurationFile::AddPackagePathsAndWrite ( const std::string &  package_root_path  ) 

Definition at line 476 of file bbtkConfigurationFile.cxx.

References XMLNode::addChild(), XMLNode::addText(), bbtkDebugMessage, bbtkDebugMessageInc, bbtkError, XMLResults::error, eXMLErrorNone, Get_config_xml_full_path(), bbtk::GetErrorMessage(), INVALID_FILE_SEPARATOR, mBbs_paths, mPackage_paths, XMLNode::parseFile(), VALID_FILE_SEPARATOR, XMLNode::writeToFile(), and XMLCSTR.

Referenced by bbtk::WxGUIScriptingInterface::OnMenuPlugPackage().

00477   {
00478     bbtkDebugMessageInc("Config",9,
00479                         "ConfigurationFile::AddPackagePathsAndWrite("
00480                         <<path<<")"<<std::endl);
00481     
00482      XMLResults* res = new XMLResults;
00483     XMLNode BB = 
00484       XMLNode::parseFile((XMLCSTR)Get_config_xml_full_path().c_str(),
00485                          (XMLCSTR)"config",res);
00486     
00487     if ( res->error != eXMLErrorNone ) 
00488       {
00489         std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
00490         delete res;
00491         bbtkDebugMessage("Config",1,mess<< std::endl);
00492         bbtkError(mess);
00493       }
00494    delete res;
00495 
00496 #ifdef _WIN32
00497     std::string bbs_path = path + "/bbs";
00498 #else
00499     std::string bbs_path = path + "/share/bbtk/bbs" ;
00500 #endif
00501     XMLNode BBSPATH = BB.addChild((XMLCSTR)"bbs_path");
00502     BBSPATH.addText((XMLCSTR)bbs_path.c_str());
00503     Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
00504     mBbs_paths.push_back(bbs_path);
00505  
00506 #ifdef _WIN32
00507     std::string pack_path = path + "/bin";
00508 #else
00509     std::string pack_path = path ;
00510 #endif
00511     XMLNode PACKPATH = BB.addChild((XMLCSTR)"package_path");
00512     PACKPATH.addText((XMLCSTR)pack_path.c_str());
00513     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
00514     mPackage_paths.push_back(pack_path);
00515 
00516 #ifdef _WIN32
00517     pack_path = path + "/Debug";
00518     PACKPATH = BB.addChild((XMLCSTR)"package_path");
00519     PACKPATH.addText((XMLCSTR)pack_path.c_str());
00520     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
00521     mPackage_paths.push_back(pack_path);
00522     pack_path = path + "/Release";
00523     PACKPATH = BB.addChild((XMLCSTR)"package_path");
00524     PACKPATH.addText((XMLCSTR)pack_path.c_str());
00525     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
00526     mPackage_paths.push_back(pack_path);
00527 #endif
00528 
00529 
00530     XMLError err = BB.writeToFile((XMLCSTR)Get_config_xml_full_path().c_str());
00531     if ( err != eXMLErrorNone ) 
00532       {
00533         std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
00534         bbtkDebugMessage("Config",1,mess<< std::endl);
00535         bbtkError(mess);
00536       }
00537 
00538     return true;
00539   }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::ConfigurationFile::Read ( const std::string &  fileName  )  [private]

Definition at line 401 of file bbtkConfigurationFile.cxx.

References bbtkDebugMessage, bbtkError, XMLResults::error, eXMLErrorNone, XMLNode::getChildNode(), bbtk::GetErrorMessage(), GetHelp(), bbtk::GetTextOrClear(), bbtk::i, mBbs_paths, mConfig_xml_full_path, mData_path, mDefault_temp_dir, mDescription, mPackage_paths, mUrl, XMLNode::nChildNode(), XMLNode::parseFile(), and XMLCSTR.

Referenced by ConfigurationFile().

00402   {
00403     
00404     bbtkDebugMessage("Config",1,"ConfigurationFile::Read(" <<filename << ")" << std::endl);
00405     
00406     mConfig_xml_full_path = filename;
00407     XMLResults* res = new XMLResults;
00408     XMLNode BB = XMLNode::parseFile((XMLCSTR)filename.c_str(),(XMLCSTR)"config",res);
00409     
00410     if ( res->error != eXMLErrorNone ) 
00411       {
00412         std::string mess = GetErrorMessage(res,filename);
00413         delete res;
00414         bbtkDebugMessage("Config",1,mess<< std::endl);
00415         bbtkError(mess);
00416       }
00417     delete res;
00418     
00419     bbtkDebugMessage("Config",1,"OK" << std::endl);
00420   
00421     int i,j;
00422     
00423     // Description
00424     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"description"); i++) 
00425       {
00426         std::string val;
00427         GetTextOrClear(BB.getChildNode((XMLCSTR)"description",&j),val);
00428         mDescription += val;
00429       }    
00430     
00431     // Url
00432     if( BB.nChildNode((XMLCSTR)"url") ) 
00433       GetTextOrClear(BB.getChildNode((XMLCSTR)"url"),mUrl);
00434     
00435     // Data_Path
00436     if( BB.nChildNode((XMLCSTR)"data_path") ) 
00437       GetTextOrClear(BB.getChildNode((XMLCSTR)"data_path"),mData_path);
00438     
00439     // install_path
00440     //  if( BB.nChildNode((XMLCSTR)"install_path") )
00441     //   GetTextOrClear(BB.getChildNode((XMLCSTR)"install_path"),mInstall_path);
00442     
00443     // add user bbs paths
00444     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"bbs_path"); i++) 
00445       {
00446         std::string val;
00447         GetTextOrClear(BB.getChildNode((XMLCSTR)"bbs_path",&j),val);
00448         mBbs_paths.push_back(val);
00449       }
00450     
00451     // package_paths
00452     
00453     // add user package path
00454     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"package_path"); i++) 
00455       {
00456         std::string val;
00457         GetTextOrClear(BB.getChildNode((XMLCSTR)"package_path",&j),val);
00458         mPackage_paths.push_back(val);
00459       }
00460     
00461     // default_temp_dir
00462     if( BB.nChildNode((XMLCSTR)"default_temp_dir") ) 
00463       GetTextOrClear(BB.getChildNode((XMLCSTR)"default_temp_dir"),mDefault_temp_dir);
00464     
00465     if ( mDefault_temp_dir == "$") // no value found in config_xml
00466       {
00467         size_t pos = mConfig_xml_full_path.find("bbtk_config.xml");
00468         mDefault_temp_dir = mConfig_xml_full_path.substr (0,pos); 
00469       }    
00470 
00471     GetHelp(2);
00472   }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string bbtk::ConfigurationFile::GetExecutablePath (  )  [private]

Todo:
: Think to delete it!

Definition at line 215 of file bbtkConfigurationFile.cxx.

Referenced by ConfigurationFile().

00216   {
00218     char *buf = (char *)malloc(512);
00219     char *slash;
00220     
00221 #if defined(WIN32)
00222     GetModuleFileName(NULL, buf, 511);
00223     slash = strrchr(buf, '\\');
00224     if (slash)
00225       {
00226         *slash = 0;
00227       }
00228 #elif defined(__GNUC__)
00229     int res;
00230     res = readlink("/proc/self/exe", buf, 512);
00231     if (res == -1)
00232       return "";
00233     buf[res] = 0;
00234     slash = strrchr(buf, '/');
00235     if (slash)
00236       {
00237         *slash = 0;
00238       }
00239 #else
00240     return "";
00241 #endif
00242     std::string ret(buf);
00243     free(buf);
00244     return ret;
00245   }

Here is the caller graph for this function:

void bbtk::ConfigurationFile::CreateConfigXML ( char *  rootDirectory  )  [private]

Definition at line 197 of file bbtkConfigurationFile.cxx.

References bbtkDebugMessage.

Referenced by InstallPath().

00198   {
00199     FILE *fp;
00200     char configXml[250];
00201     sprintf (configXml , "%s/bbtk_config.xml", rootDirectory);
00202     bbtkDebugMessage("Config",1, "in CreateConfigXML[" << configXml << "]" << std::endl);
00203     fp = fopen (configXml, "w");
00204     fprintf(fp, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
00205     fprintf(fp, "<config>\n");
00206     fprintf(fp, "   <bbs_path>     </bbs_path>\n");
00207     fprintf(fp, "   <package_path> </package_path>\n");
00208     fprintf(fp, "</config>\n");
00209     fclose(fp);
00210   }

Here is the caller graph for this function:


Member Data Documentation

std::string bbtk::ConfigurationFile::mDescription [private]

Definition at line 130 of file bbtkConfigurationFile.h.

Referenced by Read().

std::string bbtk::ConfigurationFile::mConfig_xml_full_path [private]

Where is the file bbtk_config.xml.

Definition at line 132 of file bbtkConfigurationFile.h.

Referenced by Read().

std::string bbtk::ConfigurationFile::mBin_path [private]

Set automatically : The path to the executable (usually bbi)

Definition at line 136 of file bbtkConfigurationFile.h.

Referenced by ConfigurationFile().

std::string bbtk::ConfigurationFile::mInstall_path [private]

The path to the install prefix (=mBinPath+"/..").

Definition at line 138 of file bbtkConfigurationFile.h.

Referenced by ConfigurationFile().

std::string bbtk::ConfigurationFile::mDoc_rel_path [private]

The relative path to the doc folder (=BBTK_DOC_REL_PATH).

Definition at line 140 of file bbtkConfigurationFile.h.

Referenced by ConfigurationFile().

std::string bbtk::ConfigurationFile::mDoc_path [private]

The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path).

Definition at line 142 of file bbtkConfigurationFile.h.

Referenced by ConfigurationFile().

std::string bbtk::ConfigurationFile::mBbs_rel_path [private]

The relative path to the doc folder (=BBTK_BBS_REL_PATH).

Definition at line 144 of file bbtkConfigurationFile.h.

Referenced by ConfigurationFile().

std::string bbtk::ConfigurationFile::mBbs_path [private]

The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path).

Definition at line 146 of file bbtkConfigurationFile.h.

Referenced by ConfigurationFile().

std::string bbtk::ConfigurationFile::mRsc_rel_path [private]

The relative path to the rsc folder (=BBTK_RSC_REL_PATH).

Definition at line 148 of file bbtkConfigurationFile.h.

std::string bbtk::ConfigurationFile::mRsc_path [private]

The path to the rsc folder (=mInstall_path+"/"+mRsc_rel_path).

Definition at line 150 of file bbtkConfigurationFile.h.

std::string bbtk::ConfigurationFile::mData_path [private]

The path to the bbtk data folder Initialized to mInstall_path+"/"+BBTK_DATA_REL_PATH But can be overriden by value read from bbtk_config.xml

Definition at line 154 of file bbtkConfigurationFile.h.

Referenced by ConfigurationFile(), and Read().

std::string bbtk::ConfigurationFile::mFile_separator [private]

/ or \, depending on the OS

Definition at line 157 of file bbtkConfigurationFile.h.

Referenced by ConfigurationFile().

std::string bbtk::ConfigurationFile::mUrl [private]

Read from bbtk_config.xml file Where the doc is

Definition at line 161 of file bbtkConfigurationFile.h.

Referenced by Read().

std::vector<std::string> bbtk::ConfigurationFile::mBbs_paths [private]

Scripts.

Definition at line 163 of file bbtkConfigurationFile.h.

Referenced by AddPackagePathsAndWrite(), ConfigurationFile(), and Read().

std::vector<std::string> bbtk::ConfigurationFile::mPackage_paths [private]

Package dlls.

Definition at line 165 of file bbtkConfigurationFile.h.

Referenced by AddPackagePathsAndWrite(), ConfigurationFile(), and Read().

std::vector<std::string> bbtk::ConfigurationFile::mExt_dll_paths [private]

If Packages link against extern dlls.

Definition at line 167 of file bbtkConfigurationFile.h.

std::string bbtk::ConfigurationFile::mDefault_temp_dir [private]

Temp directory for generated data.

Definition at line 169 of file bbtkConfigurationFile.h.

Referenced by Read().


The documentation for this class was generated from the following files:

Generated on Wed Nov 12 11:38:42 2008 for BBTK by  doxygen 1.5.6