Skip to content

Commit

Permalink
integrate NCriticalPathParameters saving into the QLSettingsManager
Browse files Browse the repository at this point in the history
  • Loading branch information
w0lek committed Nov 24, 2023
1 parent 7d9bc32 commit 13d7544
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
21 changes: 15 additions & 6 deletions src/InteractivePathAnalysis/ncriticalpathparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,16 @@ int NCriticalPathParameters::getIntValue(const std::string& category, const std:
int result = 0;

std::string resultStr = getStringValue(category, subcategory, parameter);

try {
result = std::atoi(resultStr.c_str());
} catch(...) {
SimpleLogger::instance().error("cannot convert", resultStr.c_str(), "value for", category.c_str(), subcategory.c_str(), parameter.c_str());
if (resultStr == "checked") {
result = 1;
} else if (resultStr == "unchecked") {
result = 0;
} else {
try {
result = std::atoi(resultStr.c_str());
} catch(...) {
SimpleLogger::instance().error("cannot convert", resultStr.c_str(), "value for", category.c_str(), subcategory.c_str(), parameter.c_str());
}
}

return result;
Expand Down Expand Up @@ -253,7 +258,11 @@ bool NCriticalPathParameters::loadFromFile(nlohmann::json& json)
}
}

std::string NCriticalPathParameters::filePath() const
std::filesystem::path NCriticalPathParameters::filePath() const
{
#ifdef STANDALONE_APP
return "ipa.json";
#else
return FOEDAG::QLSettingsManager::getInstance()->settings_json_filepath;
#endif
}
13 changes: 7 additions & 6 deletions src/InteractivePathAnalysis/ncriticalpathparameters.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#pragma once

#include <client/keys.h>
#include "client/keys.h"

#include "nlohmann_json/json.hpp"

#include <filesystem>
#include <string>
#include <memory>

class NCriticalPathParameters {
const char* KEY_USER_VALUE = "userValue";
const char* KEY_DEFAULT_VALUE = "default";

const char* CATEGORY = "ipa";
const char* CATEGORY = "IPA";
const char* SUBCATEGORY_PATHLIST = "pathlist";
#ifdef ENABLE_FILTER_SAVE_SETTINGS_FEATURE
const char* SUBCATEGORY_FILTER = "filter";
Expand All @@ -29,12 +30,12 @@ class NCriticalPathParameters {
const char* DEFAULT_VALUE_PATHLIST_PARAMETER_TYPE = KEY_SETUP_PATH_LIST;
const char* DEFAULT_VALUE_PATHLIST_PARAMETER_DETAIL_LEVEL = "0";
const char* DEFAULT_VALUE_PATHLIST_PARAMETER_MAX_NUM = "100";
const char* DEFAULT_VALUE_PATHLIST_PARAMETER_SAVE_SETTINGS = "1";
const char* DEFAULT_VALUE_PATHLIST_PARAMETER_SAVE_SETTINGS = "checked";
#ifdef ENABLE_FILTER_SAVE_SETTINGS_FEATURE
const char* DEFAULT_VALUE_FILTER_PARAMETER_SAVE_SETTINGS = "0";
const char* DEFAULT_VALUE_FILTER_PARAMETER_SAVE_SETTINGS = "unchecked";
#endif
#ifdef STANDALONE_APP
const char* DEFAULT_VALUE_PATHLIST_PARAMETER_IS_FLAT_ROUTING = "0";
const char* DEFAULT_VALUE_PATHLIST_PARAMETER_IS_FLAT_ROUTING = "unchecked";
#endif

public:
Expand Down Expand Up @@ -83,7 +84,7 @@ class NCriticalPathParameters {
int getIntValue(const std::string& category, const std::string& subcategory, const std::string& parameter) const;
std::string getStringValue(const std::string& category, const std::string& subcategory, const std::string& parameter, bool forceReturnDefaultValue=false) const;

std::string filePath() const;
std::filesystem::path filePath() const;

bool loadFromFile(nlohmann::json& json);
void saveToFile(const nlohmann::json& json);
Expand Down

0 comments on commit 13d7544

Please sign in to comment.