|
From: Emilien K. <cur...@us...> - 2005-08-11 09:58:31
|
Update of /cvsroot/wxdevcenter/wxDevCenter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18216/src Modified Files: Application.cpp Config.cpp Log Message: Add command line parser to allow to add paths to include data/features/plugins/config. Index: Config.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/Config.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Config.cpp 7 Mar 2005 15:23:03 -0000 1.9 --- Config.cpp 11 Aug 2005 09:58:17 -0000 1.10 *************** *** 86,87 **** --- 86,210 ---- m_SubConfigMap.clear(); } + + + ////////////////////////////////////////////////////////////////////// + // Configuration système + + // Retourne le chemin d'instalation de l'application. + wxString Config::GetInstallPath() + { + return m_strInstallPath; + } + + // Retourne le chemin racine des données (images, icones, etc). + wxString Config::GetDataPath(long lStackIndex) + { + if(lStackIndex>=0l && lStackIndex<(long)m_strDataPath.GetCount()) + return m_strDataPath[lStackIndex]; + else + return wxT(""); + } + + // Retourne le chemin racine des fonctionnalités. + wxString Config::GetFeaturesPath(long lStackIndex) + { + if(lStackIndex>=0l && lStackIndex<(long)m_strFeaturesPath.GetCount()) + return m_strFeaturesPath[lStackIndex]; + else + return wxT(""); + } + + // Retourne le chemin racine des pluggins. + wxString Config::GetPluginsPath(long lStackIndex) + { + if(lStackIndex>=0l && lStackIndex<(long)m_strPluginsPath.GetCount()) + return m_strPluginsPath[lStackIndex]; + else + return wxT(""); + } + + // Retourne le chemin racine de la configuration globale. + wxString Config::GetGlobalConfPath(long lStackIndex) + { + if(lStackIndex>=0l && lStackIndex<(long)m_strConfPath.GetCount()) + return m_strConfPath[lStackIndex]; + else + return wxT(""); + } + + // Retourne le chemin racine de la configuration utilisateur. + wxString Config::GetUserConfPath(long lStackIndex) + { + if(lStackIndex>=0l && lStackIndex<(long)m_strUserConfPath.GetCount()) + return m_strUserConfPath[lStackIndex]; + else + return wxT(""); + } + + // Ajoute un chemin sur la pile des chemins de stockage de données. + void Config::AddDataPath(wxString strPath) + { + m_strDataPath.Insert(strPath, 0); + } + + // Ajoute un chemin sur la pile des chemins des features. + void Config::AddFeaturesPath(wxString strPath) + { + m_strFeaturesPath.Insert(strPath, 0); + } + + // Ajoute un chemin sur la pile des chemins des plugins. + void Config::AddPluginsPath(wxString strPath) + { + m_strPluginsPath.Insert(strPath, 0); + } + + // Ajoute un chemin sur la pile des chemins de configuration globale. + void Config::AddGlobalConfPath(wxString strPath) + { + m_strConfPath.Insert(strPath, 0); + } + + // Ajoute un chemin sur la pile des chemins de configuration utilisateur. + void Config::AddUserConfPath(wxString strPath) + { + m_strUserConfPath.Insert(strPath, 0); + } + + // Log la configuration courante vers le flux d'informations. + void Config::LogConfig() + { + long l; + wxString str; + + wxLogDebug(wxT("Configuration :")); + + wxLogDebug(wxT("Installation path : %s"), GetInstallPath().GetData()); + + wxLogDebug(wxT("Data path :")); + l = 0; + while(str=GetDataPath(l++), !str.IsEmpty()) + wxLogDebug(wxT(" - %s"), str.GetData()); + + wxLogDebug(wxT("Features path :")); + l = 0; + while(str=GetFeaturesPath(l++), !str.IsEmpty()) + wxLogDebug(wxT(" - %s"), str.GetData()); + + wxLogDebug(wxT("Plugins path :")); + l = 0; + while(str=GetPluginsPath(l++), !str.IsEmpty()) + wxLogDebug(wxT(" - %s"), str.GetData()); + + wxLogDebug(wxT("Global config path :")); + l = 0; + while(str=GetGlobalConfPath(l++), !str.IsEmpty()) + wxLogDebug(wxT(" - %s"), str.GetData()); + + wxLogDebug(wxT("User config path :")); + l = 0; + while(str=GetUserConfPath(l++), !str.IsEmpty()) + wxLogDebug(wxT(" - %s"), str.GetData()); + + } + Index: Application.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/Application.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Application.cpp 5 Aug 2005 18:59:11 -0000 1.25 --- Application.cpp 11 Aug 2005 09:58:17 -0000 1.26 *************** *** 38,41 **** --- 38,44 ---- #include <wx/sysopt.h> #include <wx/tokenzr.h> + #include <wx/datetime.h> + #include <wx/cmdline.h> + // Utilisation du namespace *************** *** 46,51 **** END_EVENT_TABLE() - #include <wx/datetime.h> - Application* Application::ms_pTheApp = NULL; --- 49,52 ---- *************** *** 61,66 **** SetVendorName(WXDC_SETUP_VENDOR); ! // Initialise les gestionnaires m_ConfigManager.Initialize(); m_DocManager.Initialize(); m_ProjectManager.Initialize(); --- 62,74 ---- SetVendorName(WXDC_SETUP_VENDOR); ! // Initialisation du gestionnaire de configuration. m_ConfigManager.Initialize(); + + if(!wxApp::OnInit()) + return false; + + m_ConfigManager.LogConfig(); + + // Initialise les gestionnaires m_DocManager.Initialize(); m_ProjectManager.Initialize(); *************** *** 463,464 **** --- 471,505 ---- + // Initialise la ligne de commande. + void Application::OnInitCmdLine(wxCmdLineParser& parser) + { + wxApp::OnInitCmdLine(parser); + + parser.AddOption(wxT("APd"), wxT("addpath-data"), WXDC_CMDLINE_ADDPATH_DATA, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE); + parser.AddOption(wxT("APf"), wxT("addpath-features"), WXDC_CMDLINE_ADDPATH_FEATURES, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE); + parser.AddOption(wxT("APp"), wxT("addpath-plugins"), WXDC_CMDLINE_ADDPATH_PLUGINS, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE); + parser.AddOption(wxT("APc"), wxT("addpath-conf"), WXDC_CMDLINE_ADDPATH_CONF, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE); + parser.AddOption(wxT("APu"), wxT("addpath-userconf"), WXDC_CMDLINE_ADDPATH_USERCONF, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE); + } + + // Parse la ligne de commande pour récupérer toutes les options voulues. + bool Application::OnCmdLineParsed(wxCmdLineParser& parser) + { + if(!wxApp::OnCmdLineParsed(parser)) + return false; + + wxString str; + if(parser.Found(wxT("APd"), (wxString*)&str)) + GetConfig().AddDataPath(str); + if(parser.Found(wxT("APf"), (wxString*)&str)) + GetConfig().AddFeaturesPath(str); + if(parser.Found(wxT("APp"), (wxString*)&str)) + GetConfig().AddPluginsPath(str); + if(parser.Found(wxT("APc"), (wxString*)&str)) + GetConfig().AddGlobalConfPath(str); + if(parser.Found(wxT("APu"), (wxString*)&str)) + GetConfig().AddUserConfPath(str); + wxLogDebug("Plop"); + return true; + } + |