From 42687303ae4a17e8e2f7e00d46e79b309f5e12a9 Mon Sep 17 00:00:00 2001 From: parth-gr <50455445+parth-gr@users.noreply.github.com> Date: Thu, 3 Sep 2020 00:52:42 +0530 Subject: [PATCH] Updated Json2configurationprovider.cpp to avoid automatic merges Signed-off-by: parth-gr <50455445+parth-gr@users.noreply.github.com> --- .../src/json2configurationprovider.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Source/moja.flint.configuration/src/json2configurationprovider.cpp b/Source/moja.flint.configuration/src/json2configurationprovider.cpp index e573ef3..325b100 100644 --- a/Source/moja.flint.configuration/src/json2configurationprovider.cpp +++ b/Source/moja.flint.configuration/src/json2configurationprovider.cpp @@ -7,6 +7,7 @@ #include "moja/flint/configuration/localdomain.h" #include "moja/flint/configuration/spinup.h" +#include #include #include @@ -33,6 +34,7 @@ namespace flint { namespace configuration { JSON2ConfigurationProvider::JSON2ConfigurationProvider(const std::vector& configFilePath) { + MOJA_PROFILE_FUNCTION(); for (const std::string configFie : configFilePath) { Poco::File file(configFie); if (!file.exists()) { @@ -46,6 +48,7 @@ JSON2ConfigurationProvider::JSON2ConfigurationProvider(const std::vector& configFilePath, const std::vector& configProviderFilePath) { + MOJA_PROFILE_FUNCTION(); for (const auto& configFie : configFilePath) { Poco::File file(configFie); if (!file.exists()) { @@ -70,6 +73,7 @@ JSON2ConfigurationProvider::JSON2ConfigurationProvider(const std::vector JSON2ConfigurationProvider::createConfiguration() { + MOJA_PROFILE_FUNCTION(); // parse the first run configuration file auto fileName = _configFilePath[0]; std::ifstream file(fileName); @@ -125,6 +129,7 @@ Parse and merge run configuration files. It only merges up to 2nd level configuration. */ void JSON2ConfigurationProvider::mergeJsonConfigFile(std::string fileName, Poco::Dynamic::Var parsedResult) { + MOJA_PROFILE_FUNCTION(); auto jsonStructFinal = parsedResult.extract(); std::ifstream file(fileName); @@ -176,6 +181,7 @@ Parse and merge data provider configuration files it merges only raster-tiled layers configuration. It assumes that other configurations are identical. */ void JSON2ConfigurationProvider::mergeJsonProviderConfigFile(std::string fileName, Poco::Dynamic::Var parsedResult) { + MOJA_PROFILE_FUNCTION(); auto jsonStructFinal = parsedResult.extract(); auto providerFinal = jsonStructFinal->getObject("Providers"); std::ifstream file(fileName); @@ -240,6 +246,7 @@ void JSON2ConfigurationProvider::mergeJsonProviderConfigFile(std::string fileNam } void JSON2ConfigurationProvider::createLocalDomain(Poco::Dynamic::Var& parsedJSON, Configuration& config) const { + MOJA_PROFILE_FUNCTION(); Poco::DynamicStruct jsonStruct = *parsedJSON.extract(); auto localDomainStruct = jsonStruct["LocalDomain"].extract(); const auto localDomainType = parseLocalDomainType(localDomainStruct["type"]); @@ -298,7 +305,7 @@ void JSON2ConfigurationProvider::createLocalDomain(Poco::Dynamic::Var& parsedJSO config.setLocalDomain(localDomainType, iterationType, doLogging, numThreads, sequencerLibrary, sequencer, simulateLandUnit, landUnitBuildSuccess, settings, stepping); - config.localDomain()->setLandscapeObject(landscape["provider"].extract(), iterationType); + config.localDomain()->setLandscapeObject(landscape["provider"].extract(), iterationType); auto landscapeObject = config.localDomain()->landscapeObject(); switch (iterationType) { @@ -392,6 +399,7 @@ void JSON2ConfigurationProvider::createLocalDomain(Poco::Dynamic::Var& parsedJSO } void JSON2ConfigurationProvider::createSpinup(Poco::Dynamic::Var& parsedJSON, Configuration& config) const { + MOJA_PROFILE_FUNCTION(); Poco::DynamicStruct jsonStruct = *parsedJSON.extract(); if (!jsonStruct.contains("Spinup")) { DynamicObject settings; @@ -426,6 +434,7 @@ void JSON2ConfigurationProvider::createSpinup(Poco::Dynamic::Var& parsedJSON, Co } void JSON2ConfigurationProvider::createLibraries(Poco::Dynamic::Var& parsedJSON, Configuration& config) const { + MOJA_PROFILE_FUNCTION(); Poco::DynamicStruct jsonStruct = *parsedJSON.extract(); auto librariesStruct = jsonStruct["Libraries"].extract(); for (auto item : librariesStruct) { @@ -445,11 +454,13 @@ void JSON2ConfigurationProvider::createLibraries(Poco::Dynamic::Var& parsedJSON, } bool JSON2ConfigurationProvider::fileExists(const std::string& path) { + MOJA_PROFILE_FUNCTION(); Poco::File pf(path); return pf.exists(); } void JSON2ConfigurationProvider::createProviders(Poco::Dynamic::Var& parsedJSON, Configuration& config) const { + MOJA_PROFILE_FUNCTION(); auto jsonStruct2 = *parsedJSON.extract(); auto provider = jsonStruct2.getObject("Providers"); auto& data = *(provider.get()); @@ -531,6 +542,7 @@ void JSON2ConfigurationProvider::createPools(Poco::Dynamic::Var& parsedJSON, Con bool JSON2ConfigurationProvider::createSpecialPools(const std::string& poolName, const DynamicStruct& poolSettings, Configuration& config) const { + MOJA_PROFILE_FUNCTION(); if (!poolSettings.contains("transform")) { return false; } @@ -552,6 +564,8 @@ bool JSON2ConfigurationProvider::createSpecialPools(const std::string& poolName, bool JSON2ConfigurationProvider::createSpecialVariables( const std::pair& keyValPair, Configuration& config, bool isSpinup) const { + + MOJA_PROFILE_FUNCTION(); auto spinup = config.spinup(); auto varName = keyValPair.first; if (keyValPair.second.isStruct()) { @@ -585,6 +599,7 @@ bool JSON2ConfigurationProvider::createSpecialVariables( void JSON2ConfigurationProvider::createVariables(Poco::Dynamic::Var& parsedJSON, Configuration& config, bool isSpinup) const { + MOJA_PROFILE_FUNCTION(); auto spinup = config.spinup(); const std::string configSection = isSpinup ? "SpinupVariables" : "Variables"; @@ -630,6 +645,7 @@ void JSON2ConfigurationProvider::createVariables(Poco::Dynamic::Var& parsedJSON, } void JSON2ConfigurationProvider::createModules(Poco::Dynamic::Var& parsedJSON, Configuration& config) const { + MOJA_PROFILE_FUNCTION(); Poco::DynamicStruct jsonStruct = *parsedJSON.extract(); auto modulesStruct = jsonStruct["Modules"].extract(); for (auto item : modulesStruct) { @@ -653,13 +669,14 @@ void JSON2ConfigurationProvider::createModules(Poco::Dynamic::Var& parsedJSON, C isProxy = moduleStruct["is_proxy"].extract(); } - const auto settings = parsePocoVarToDynamic(moduleStruct["settings"]); + const auto settings = parsePocoVarToDynamic(moduleStruct["settings"]); config.addModule(moduleLibraryName, item.first, moduleOrder, isProxy, settings.isEmpty() ? DynamicObject() : settings.extract()); } } void JSON2ConfigurationProvider::createSpinupModules(Poco::Dynamic::Var& parsedJSON, Configuration& config) const { + MOJA_PROFILE_FUNCTION(); Poco::DynamicStruct jsonStruct = *parsedJSON.extract(); auto modulesStruct = jsonStruct["SpinupModules"].extract(); for (auto item : modulesStruct) {