Replaced init() functions with proper constructors in ProjectConfig structs
This commit is contained in:
@@ -170,7 +170,6 @@ void Application::shutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProjectConfig Application::extractConfig() {
|
ProjectConfig Application::extractConfig() {
|
||||||
auto appConfig = ProjectConfig();
|
|
||||||
auto currentPath = std::filesystem::current_path().string();
|
auto currentPath = std::filesystem::current_path().string();
|
||||||
auto jsonConfigFile = QFile(QString::fromStdString(currentPath + "/bloom.json"));
|
auto jsonConfigFile = QFile(QString::fromStdString(currentPath + "/bloom.json"));
|
||||||
|
|
||||||
@@ -185,10 +184,9 @@ ProjectConfig Application::extractConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto jsonObject = QJsonDocument::fromJson(jsonConfigFile.readAll()).object();
|
auto jsonObject = QJsonDocument::fromJson(jsonConfigFile.readAll()).object();
|
||||||
appConfig.init(jsonObject);
|
|
||||||
|
|
||||||
jsonConfigFile.close();
|
jsonConfigFile.close();
|
||||||
return appConfig;
|
|
||||||
|
return ProjectConfig(jsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Application::presentHelpText() {
|
int Application::presentHelpText() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
using namespace Bloom;
|
using namespace Bloom;
|
||||||
|
|
||||||
void ProjectConfig::init(const QJsonObject& jsonObject) {
|
ProjectConfig::ProjectConfig(const QJsonObject& jsonObject) {
|
||||||
if (!jsonObject.contains("environments")) {
|
if (!jsonObject.contains("environments")) {
|
||||||
throw Exceptions::InvalidConfig(
|
throw Exceptions::InvalidConfig(
|
||||||
"No environments found - please review the bloom.json configuration file and ensure that "
|
"No environments found - please review the bloom.json configuration file and ensure that "
|
||||||
@@ -19,12 +19,13 @@ void ProjectConfig::init(const QJsonObject& jsonObject) {
|
|||||||
auto environmentName = environmentIt.key().toStdString();
|
auto environmentName = environmentIt.key().toStdString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto environmentConfig = EnvironmentConfig();
|
|
||||||
environmentConfig.init(environmentName, environmentIt.value().toObject());
|
|
||||||
|
|
||||||
this->environments.insert(
|
this->environments.insert(
|
||||||
std::pair<std::string, EnvironmentConfig>(environmentName, environmentConfig)
|
std::pair(
|
||||||
|
environmentName,
|
||||||
|
EnvironmentConfig(environmentName, environmentIt.value().toObject())
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch (Exceptions::InvalidConfig& exception) {
|
} catch (Exceptions::InvalidConfig& exception) {
|
||||||
Logger::error("Invalid environment config for environment '" + environmentName + "': "
|
Logger::error("Invalid environment config for environment '" + environmentName + "': "
|
||||||
+ exception.getMessage() + " Environment will be ignored.");
|
+ exception.getMessage() + " Environment will be ignored.");
|
||||||
@@ -32,13 +33,11 @@ void ProjectConfig::init(const QJsonObject& jsonObject) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains("debugServer")) {
|
if (jsonObject.contains("debugServer")) {
|
||||||
auto debugServerConfig = DebugServerConfig();
|
this->debugServerConfig = DebugServerConfig(jsonObject.find("debugServer")->toObject());
|
||||||
debugServerConfig.init(jsonObject.find("debugServer")->toObject());
|
|
||||||
this->debugServerConfig = debugServerConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains("insight")) {
|
if (jsonObject.contains("insight")) {
|
||||||
this->insightConfig.init(jsonObject.find("insight")->toObject());
|
this->insightConfig = InsightConfig(jsonObject.find("insight")->toObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains("debugLoggingEnabled")) {
|
if (jsonObject.contains("debugLoggingEnabled")) {
|
||||||
@@ -46,13 +45,13 @@ void ProjectConfig::init(const QJsonObject& jsonObject) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsightConfig::init(const QJsonObject& jsonObject) {
|
InsightConfig::InsightConfig(const QJsonObject& jsonObject) {
|
||||||
if (jsonObject.contains("enabled")) {
|
if (jsonObject.contains("enabled")) {
|
||||||
this->insightEnabled = jsonObject.find("enabled").value().toBool();
|
this->insightEnabled = jsonObject.find("enabled").value().toBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentConfig::init(std::string name, QJsonObject jsonObject) {
|
EnvironmentConfig::EnvironmentConfig(std::string name, QJsonObject jsonObject) {
|
||||||
if (!jsonObject.contains("debugTool")) {
|
if (!jsonObject.contains("debugTool")) {
|
||||||
throw Exceptions::InvalidConfig("No debug tool configuration provided.");
|
throw Exceptions::InvalidConfig("No debug tool configuration provided.");
|
||||||
}
|
}
|
||||||
@@ -62,23 +61,19 @@ void EnvironmentConfig::init(std::string name, QJsonObject jsonObject) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->name = std::move(name);
|
this->name = std::move(name);
|
||||||
this->debugToolConfig.init(jsonObject.find("debugTool")->toObject());
|
this->debugToolConfig = DebugToolConfig(jsonObject.find("debugTool")->toObject());
|
||||||
this->targetConfig.init(jsonObject.find("target")->toObject());
|
this->targetConfig = TargetConfig(jsonObject.find("target")->toObject());
|
||||||
|
|
||||||
if (jsonObject.contains("debugServer")) {
|
if (jsonObject.contains("debugServer")) {
|
||||||
auto debugServerConfig = DebugServerConfig();
|
this->debugServerConfig = DebugServerConfig(jsonObject.find("debugServer")->toObject());
|
||||||
debugServerConfig.init(jsonObject.find("debugServer")->toObject());
|
|
||||||
this->debugServerConfig = debugServerConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains("insight")) {
|
if (jsonObject.contains("insight")) {
|
||||||
auto insightConfig = InsightConfig();
|
this->insightConfig = InsightConfig(jsonObject.find("insight")->toObject());
|
||||||
insightConfig.init(jsonObject.find("insight")->toObject());
|
|
||||||
this->insightConfig = insightConfig;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetConfig::init(const QJsonObject& jsonObject) {
|
TargetConfig::TargetConfig(const QJsonObject& jsonObject) {
|
||||||
if (!jsonObject.contains("name")) {
|
if (!jsonObject.contains("name")) {
|
||||||
throw Exceptions::InvalidConfig("No target name found.");
|
throw Exceptions::InvalidConfig("No target name found.");
|
||||||
}
|
}
|
||||||
@@ -92,7 +87,7 @@ void TargetConfig::init(const QJsonObject& jsonObject) {
|
|||||||
this->jsonObject = jsonObject;
|
this->jsonObject = jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugToolConfig::init(const QJsonObject& jsonObject) {
|
DebugToolConfig::DebugToolConfig(const QJsonObject& jsonObject) {
|
||||||
if (!jsonObject.contains("name")) {
|
if (!jsonObject.contains("name")) {
|
||||||
throw Exceptions::InvalidConfig("No debug tool name found.");
|
throw Exceptions::InvalidConfig("No debug tool name found.");
|
||||||
}
|
}
|
||||||
@@ -106,7 +101,7 @@ void DebugToolConfig::init(const QJsonObject& jsonObject) {
|
|||||||
this->jsonObject = jsonObject;
|
this->jsonObject = jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugServerConfig::init(const QJsonObject& jsonObject) {
|
DebugServerConfig::DebugServerConfig(const QJsonObject& jsonObject) {
|
||||||
this->name = jsonObject.find("name")->toString().toLower().toStdString();
|
this->name = jsonObject.find("name")->toString().toLower().toStdString();
|
||||||
this->jsonObject = jsonObject;
|
this->jsonObject = jsonObject;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,13 +42,6 @@ namespace Bloom
|
|||||||
*/
|
*/
|
||||||
struct TargetConfig
|
struct TargetConfig
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Obtains config parameters from JSON object.
|
|
||||||
*
|
|
||||||
* @param jsonObject
|
|
||||||
*/
|
|
||||||
void init(const QJsonObject& jsonObject);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the selected target.
|
* The name of the selected target.
|
||||||
*/
|
*/
|
||||||
@@ -62,6 +55,15 @@ namespace Bloom
|
|||||||
std::optional<std::string> variantName;
|
std::optional<std::string> variantName;
|
||||||
|
|
||||||
QJsonObject jsonObject;
|
QJsonObject jsonObject;
|
||||||
|
|
||||||
|
TargetConfig() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains config parameters from JSON object.
|
||||||
|
*
|
||||||
|
* @param jsonObject
|
||||||
|
*/
|
||||||
|
explicit TargetConfig(const QJsonObject& jsonObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,13 +75,6 @@ namespace Bloom
|
|||||||
*/
|
*/
|
||||||
struct DebugToolConfig
|
struct DebugToolConfig
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Obtains config parameters from JSON object.
|
|
||||||
*
|
|
||||||
* @param jsonObject
|
|
||||||
*/
|
|
||||||
void init(const QJsonObject& jsonObject);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the selected debug tool.
|
* The name of the selected debug tool.
|
||||||
*/
|
*/
|
||||||
@@ -95,6 +90,15 @@ namespace Bloom
|
|||||||
bool releasePostDebugSession = true;
|
bool releasePostDebugSession = true;
|
||||||
|
|
||||||
QJsonObject jsonObject;
|
QJsonObject jsonObject;
|
||||||
|
|
||||||
|
DebugToolConfig() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains config parameters from JSON object.
|
||||||
|
*
|
||||||
|
* @param jsonObject
|
||||||
|
*/
|
||||||
|
explicit DebugToolConfig(const QJsonObject& jsonObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,27 +106,31 @@ namespace Bloom
|
|||||||
*/
|
*/
|
||||||
struct DebugServerConfig
|
struct DebugServerConfig
|
||||||
{
|
{
|
||||||
|
std::string name;
|
||||||
|
QJsonObject jsonObject;
|
||||||
|
|
||||||
|
DebugServerConfig() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains config parameters from JSON object.
|
* Obtains config parameters from JSON object.
|
||||||
*
|
*
|
||||||
* @param jsonObject
|
* @param jsonObject
|
||||||
*/
|
*/
|
||||||
void init(const QJsonObject& jsonObject);
|
explicit DebugServerConfig(const QJsonObject& jsonObject);
|
||||||
|
|
||||||
std::string name;
|
|
||||||
QJsonObject jsonObject;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InsightConfig
|
struct InsightConfig
|
||||||
{
|
{
|
||||||
|
bool insightEnabled = true;
|
||||||
|
|
||||||
|
InsightConfig() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains config parameters from JSON object.
|
* Obtains config parameters from JSON object.
|
||||||
*
|
*
|
||||||
* @param jsonObject
|
* @param jsonObject
|
||||||
*/
|
*/
|
||||||
void init(const QJsonObject& jsonObject);
|
explicit InsightConfig(const QJsonObject& jsonObject);
|
||||||
|
|
||||||
bool insightEnabled = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,13 +141,6 @@ namespace Bloom
|
|||||||
*/
|
*/
|
||||||
struct EnvironmentConfig
|
struct EnvironmentConfig
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Obtains config parameters from JSON object.
|
|
||||||
*
|
|
||||||
* @param jsonObject
|
|
||||||
*/
|
|
||||||
void init(std::string name, QJsonObject jsonObject);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The environment name is stored as the key to the JSON object containing the environment parameters.
|
* The environment name is stored as the key to the JSON object containing the environment parameters.
|
||||||
*
|
*
|
||||||
@@ -171,6 +172,13 @@ namespace Bloom
|
|||||||
* Insight configuration can be defined at an environment level as well as at an application level.
|
* Insight configuration can be defined at an environment level as well as at an application level.
|
||||||
*/
|
*/
|
||||||
std::optional<InsightConfig> insightConfig;
|
std::optional<InsightConfig> insightConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains config parameters from JSON object.
|
||||||
|
*
|
||||||
|
* @param jsonObject
|
||||||
|
*/
|
||||||
|
EnvironmentConfig(std::string name, QJsonObject jsonObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,13 +186,6 @@ namespace Bloom
|
|||||||
*/
|
*/
|
||||||
struct ProjectConfig
|
struct ProjectConfig
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Obtains config parameters from JSON object.
|
|
||||||
*
|
|
||||||
* @param jsonObject
|
|
||||||
*/
|
|
||||||
void init(const QJsonObject& jsonObject);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mapping of environment names to EnvironmentConfig objects.
|
* A mapping of environment names to EnvironmentConfig objects.
|
||||||
*/
|
*/
|
||||||
@@ -196,8 +197,19 @@ namespace Bloom
|
|||||||
*/
|
*/
|
||||||
std::optional<DebugServerConfig> debugServerConfig;
|
std::optional<DebugServerConfig> debugServerConfig;
|
||||||
|
|
||||||
InsightConfig insightConfig;
|
/**
|
||||||
|
* Application level Insight configuration. We use this as a fallback if no Insight config is provided at
|
||||||
|
* the environment level.
|
||||||
|
*/
|
||||||
|
std::optional<InsightConfig> insightConfig;
|
||||||
|
|
||||||
bool debugLoggingEnabled = false;
|
bool debugLoggingEnabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains config parameters from JSON object.
|
||||||
|
*
|
||||||
|
* @param jsonObject
|
||||||
|
*/
|
||||||
|
explicit ProjectConfig(const QJsonObject& jsonObject);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user