Skip to content
Snippets Groups Projects
Commit 02a78fca authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[AL] Add parsing of parameters in ProjectData.

parent 535b3673
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,9 @@ ProjectData::ProjectData(ConfigTree const& project_config,
// process variables
parseProcessVariables(project_config.get_child("process_variables"));
// parameters
parseParameters(project_config.get_child("parameters"));
// processes
parseProcesses(project_config.get_child("processes"));
......@@ -190,6 +193,55 @@ void ProjectData::parseProcessVariables(
}
}
void ProjectData::parseParameters(ConfigTree const& parameters_config)
{
using namespace ProcessLib;
DBUG("Reading parameters:");
for (auto pc_it : parameters_config)
{
// Skip non-parameter section.
if (pc_it.first != "parameter")
continue;
ConfigTree const& parameter_config = pc_it.second;
auto name = parameter_config.get_optional<std::string>("name");
if (!name)
{
ERR("The parameter config does not provide a name tag.");
std::abort();
}
auto type = parameter_config.get_optional<std::string>("type");
if (!type)
{
ERR("Could not find required parameter type.");
std::abort();
}
// Create parameter based on the provided type.
if (*type == "Constant")
{
INFO("ConstantParameter: %s.", name->c_str());
_parameters.push_back(createConstParameter(parameter_config));
_parameters.back()->name = *name;
}
else if (*type == "MeshProperty")
{
INFO("MeshPropertyParameter: %s", name->c_str());
_parameters.push_back(
createMeshPropertyParameter(parameter_config, *_mesh_vec[0]));
_parameters.back()->name = *name;
}
else
{
ERR("Cannot construct property of given type \'%s\'.",
type->c_str());
std::abort();
}
}
}
void ProjectData::parseProcesses(ConfigTree const& processes_config)
{
DBUG("Reading processes:");
......
......@@ -13,6 +13,7 @@
#ifndef PROJECTDATA_H_
#define PROJECTDATA_H_
#include <memory>
#include <boost/property_tree/ptree.hpp>
#ifdef OGS_BUILD_GUI
......@@ -144,6 +145,10 @@ private:
/// variable constructor.
void parseProcessVariables(ConfigTree const& process_variables_config);
/// Parses the parameters configuration and saves them in a list.
/// Checks if a parameter has name tag.
void parseParameters(ConfigTree const& parameters_config);
/// Parses the processes configuration and creates new processes for each
/// process entry passing the corresponding subtree to the process
/// constructor.
......@@ -166,6 +171,9 @@ private:
/// Buffer for each process' config used in the process building function.
std::vector<ConfigTree> _process_configs;
/// Buffer for each parameter config passed to the process.
std::vector<std::unique_ptr<ProcessLib::ParameterBase>> _parameters;
/// Output file path with project prefix.
std::string _output_file_prefix;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment