+ add new class ParameterSerializer to load and save parameter files
This commit is contained in:
@@ -904,15 +904,31 @@ void Application::destruct(void)
|
||||
{
|
||||
// saving system parameter
|
||||
Console().Log("Saving system parameter...\n");
|
||||
_pcSysParamMngr->SaveDocument(mConfig["SystemParameter"].c_str());
|
||||
_pcSysParamMngr->SaveDocument();
|
||||
// saving the User parameter
|
||||
Console().Log("Saving system parameter...done\n");
|
||||
Console().Log("Saving user parameter...\n");
|
||||
_pcUserParamMngr->SaveDocument(mConfig["UserParameter"].c_str());
|
||||
_pcUserParamMngr->SaveDocument();
|
||||
Console().Log("Saving user parameter...done\n");
|
||||
// clean up
|
||||
delete _pcSysParamMngr;
|
||||
delete _pcUserParamMngr;
|
||||
|
||||
// now save all other parameter files
|
||||
std::map<std::string,ParameterManager *>& paramMgr = _pcSingleton->mpcPramManager;
|
||||
for (std::map<std::string,ParameterManager *>::iterator it = paramMgr.begin(); it != paramMgr.end(); ++it) {
|
||||
if ((it->second != _pcSysParamMngr) && (it->second != _pcUserParamMngr)) {
|
||||
if (it->second->HasSerializer()) {
|
||||
Console().Log("Saving %s...\n", it->first.c_str());
|
||||
it->second->SaveDocument();
|
||||
Console().Log("Saving %s...done\n", it->first.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// clean up
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
paramMgr.clear();
|
||||
_pcSysParamMngr = 0;
|
||||
_pcUserParamMngr = 0;
|
||||
|
||||
// not initialized or doubel destruct!
|
||||
assert(_pcSingleton);
|
||||
@@ -1455,10 +1471,6 @@ void Application::logStatus()
|
||||
|
||||
void Application::LoadParameters(void)
|
||||
{
|
||||
// create standard parameter sets
|
||||
_pcSysParamMngr = new ParameterManager();
|
||||
_pcUserParamMngr = new ParameterManager();
|
||||
|
||||
// Init parameter sets ===========================================================
|
||||
//
|
||||
if (mConfig.find("UserParameter") == mConfig.end())
|
||||
@@ -1466,9 +1478,15 @@ void Application::LoadParameters(void)
|
||||
if (mConfig.find("SystemParameter") == mConfig.end())
|
||||
mConfig["SystemParameter"] = mConfig["UserAppData"] + "system.cfg";
|
||||
|
||||
// create standard parameter sets
|
||||
_pcSysParamMngr = new ParameterManager();
|
||||
_pcSysParamMngr->SetSerializer(new ParameterSerializer(mConfig["SystemParameter"]));
|
||||
|
||||
_pcUserParamMngr = new ParameterManager();
|
||||
_pcUserParamMngr->SetSerializer(new ParameterSerializer(mConfig["UserParameter"]));
|
||||
|
||||
try {
|
||||
if (_pcSysParamMngr->LoadOrCreateDocument(mConfig["SystemParameter"].c_str()) && !(mConfig["Verbose"] == "Strict")) {
|
||||
if (_pcSysParamMngr->LoadOrCreateDocument() && !(mConfig["Verbose"] == "Strict")) {
|
||||
// Configuration file optional when using as Python module
|
||||
if (!Py_IsInitialized()) {
|
||||
Console().Warning(" Parameter does not exist, writing initial one\n");
|
||||
@@ -1487,7 +1505,7 @@ void Application::LoadParameters(void)
|
||||
}
|
||||
|
||||
try {
|
||||
if (_pcUserParamMngr->LoadOrCreateDocument(mConfig["UserParameter"].c_str()) && !(mConfig["Verbose"] == "Strict")) {
|
||||
if (_pcUserParamMngr->LoadOrCreateDocument() && !(mConfig["Verbose"] == "Strict")) {
|
||||
// The user parameter file doesn't exist. When an alternative parameter file is offered
|
||||
// this will be used.
|
||||
std::map<std::string, std::string>::iterator it = mConfig.find("UserParameterTemplate");
|
||||
|
||||
Reference in New Issue
Block a user