diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 9d96baa8d9f8bf5c4e9d550bb5b46b832b5a4bc3..7d7c59c2eaf112ada970c225907d8e711c3b1684 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -57,13 +57,13 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config, { std::string const geometry_file = BaseLib::copyPathToFileName( //! \ogs_file_param{prj__geometry} - project_config.getParameter<std::string>("geometry"), project_directory + project_config.getConfigParameter<std::string>("geometry"), project_directory ); detail::readGeometry(geometry_file, *_geoObjects); std::string const mesh_file = BaseLib::copyPathToFileName( //! \ogs_file_param{prj__mesh} - project_config.getParameter<std::string>("mesh"), project_directory + project_config.getConfigParameter<std::string>("mesh"), project_directory ); MeshLib::Mesh* const mesh = MeshLib::IO::readMeshFromFile(mesh_file); @@ -75,28 +75,28 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config, _mesh_vec.push_back(mesh); //! \ogs_file_param{prj__curves} - parseCurves(project_config.getSubtreeOptional("curves")); + parseCurves(project_config.getConfigSubtreeOptional("curves")); //! \ogs_file_param{prj__process_variables} - parseProcessVariables(project_config.getSubtree("process_variables")); + parseProcessVariables(project_config.getConfigSubtree("process_variables")); //! \ogs_file_param{prj__parameters} - parseParameters(project_config.getSubtree("parameters")); + parseParameters(project_config.getConfigSubtree("parameters")); //! \ogs_file_param{prj__processes} - parseProcesses(project_config.getSubtree("processes")); + parseProcesses(project_config.getConfigSubtree("processes")); //! \ogs_file_param{prj__output} - parseOutput(project_config.getSubtree("output"), output_directory); + parseOutput(project_config.getConfigSubtree("output"), output_directory); //! \ogs_file_param{prj__time_stepping} - parseTimeStepping(project_config.getSubtree("time_stepping")); + parseTimeStepping(project_config.getConfigSubtree("time_stepping")); //! \ogs_file_param{prj__linear_solvers} - parseLinearSolvers(project_config.getSubtree("linear_solvers")); + parseLinearSolvers(project_config.getConfigSubtree("linear_solvers")); //! \ogs_file_param{prj__nonlinear_solvers} - parseNonlinearSolvers(project_config.getSubtree("nonlinear_solvers")); + parseNonlinearSolvers(project_config.getConfigSubtree("nonlinear_solvers")); } ProjectData::~ProjectData() @@ -159,16 +159,16 @@ void ProjectData::buildProcesses() for (auto const& pc : _process_configs) { //! \ogs_file_param{process__type} - auto const type = pc.peekParameter<std::string>("type"); + auto const type = pc.peekConfigParameter<std::string>("type"); //! \ogs_file_param{process__nonlinear_solver} - auto const nl_slv_name = pc.getParameter<std::string>("nonlinear_solver"); + auto const nl_slv_name = pc.getConfigParameter<std::string>("nonlinear_solver"); auto& nl_slv = BaseLib::getOrError(_nonlinear_solvers, nl_slv_name, "A nonlinear solver with the given name has not been defined."); auto time_disc = NumLib::createTimeDiscretization<GlobalVector>( //! \ogs_file_param{process__time_discretization} - pc.getSubtree("time_discretization") + pc.getConfigSubtree("time_discretization") ); if (type == "GROUNDWATER_FLOW") @@ -264,7 +264,7 @@ void ProjectData::parseProcessVariables( for (auto var_config //! \ogs_file_param{prj__process_variables__process_variable} - : process_variables_config.getSubtreeList("process_variable")) { + : process_variables_config.getConfigSubtreeList("process_variable")) { // TODO Extend to referenced meshes. _process_variables.emplace_back(var_config, *_mesh_vec[0], *_geoObjects); } @@ -276,12 +276,12 @@ void ProjectData::parseParameters(BaseLib::ConfigTree const& parameters_config) DBUG("Reading parameters:"); //! \ogs_file_param{prj__parameters__parameter} - for (auto parameter_config : parameters_config.getSubtreeList("parameter")) + for (auto parameter_config : parameters_config.getConfigSubtreeList("parameter")) { //! \ogs_file_param{parameter__name} - auto name = parameter_config.getParameter<std::string>("name"); + auto name = parameter_config.getConfigParameter<std::string>("name"); //! \ogs_file_param{parameter__type} - auto type = parameter_config.peekParameter<std::string>("type"); + auto type = parameter_config.peekConfigParameter<std::string>("type"); // Create parameter based on the provided type. if (type == "Constant") @@ -310,11 +310,11 @@ void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config) { DBUG("Reading processes:"); //! \ogs_file_param{prj__processes__process} - for (auto process_config : processes_config.getSubtreeList("process")) { + for (auto process_config : processes_config.getConfigSubtreeList("process")) { // process type must be specified. //! \ogs_file_param{process__type} - process_config.peekParameter<std::string>("type"); - process_config.ignoreParameter("name"); + process_config.peekConfigParameter<std::string>("type"); + process_config.ignoreConfigParameter("name"); _process_configs.push_back(std::move(process_config)); } } @@ -323,7 +323,7 @@ void ProjectData::parseOutput(BaseLib::ConfigTree const& output_config, std::string const& output_directory) { //! \ogs_file_param{prj__output__type} - output_config.checkParameter("type", "VTK"); + output_config.checkConfigParameter("type", "VTK"); DBUG("Parse output configuration:"); _output = ProcessLib::Output<GlobalSetupType>::newInstance(output_config, output_directory); @@ -348,10 +348,10 @@ void ProjectData::parseLinearSolvers(BaseLib::ConfigTree const& config) DBUG("Reading linear solver configuration."); //! \ogs_file_param{prj__linear_solvers__linear_solver} - for (auto conf : config.getSubtreeList("linear_solver")) + for (auto conf : config.getConfigSubtreeList("linear_solver")) { //! \ogs_file_param{prj__linear_solvers__linear_solver__name} - auto const name = conf.getParameter<std::string>("name"); + auto const name = conf.getConfigParameter<std::string>("name"); BaseLib::insertIfKeyUniqueElseError(_linear_solvers, name, MathLib::createLinearSolver<GlobalMatrix, GlobalVector, @@ -365,15 +365,15 @@ void ProjectData::parseNonlinearSolvers(BaseLib::ConfigTree const& config) DBUG("Reading linear solver configuration."); //! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver} - for (auto conf : config.getSubtreeList("nonlinear_solver")) + for (auto conf : config.getConfigSubtreeList("nonlinear_solver")) { //! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver__linear_solver} - auto const ls_name = conf.getParameter<std::string>("linear_solver"); + auto const ls_name = conf.getConfigParameter<std::string>("linear_solver"); auto& linear_solver = BaseLib::getOrError(_linear_solvers, ls_name, "A linear solver with the given name does not exist."); //! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver__name} - auto const name = conf.getParameter<std::string>("name"); + auto const name = conf.getConfigParameter<std::string>("name"); BaseLib::insertIfKeyUniqueElseError(_nonlinear_solvers, name, NumLib::createNonlinearSolver<GlobalMatrix, GlobalVector>( @@ -386,9 +386,9 @@ static std::unique_ptr<MathLib::PiecewiseLinearInterpolation> createPiecewiseLinearInterpolation(BaseLib::ConfigTree const& config) { //! \ogs_file_param{prj__curves__curve__coords} - auto coords = config.getParameter<std::vector<double>>("coords"); + auto coords = config.getConfigParameter<std::vector<double>>("coords"); //! \ogs_file_param{prj__curves__curve__values} - auto values = config.getParameter<std::vector<double>>("values"); + auto values = config.getConfigParameter<std::vector<double>>("values"); if (coords.empty() || values.empty()) { ERR("The given co-ordinates or values vector is empty."); @@ -413,10 +413,10 @@ void ProjectData::parseCurves( DBUG("Reading curves configuration."); //! \ogs_file_param{prj__curves__curve} - for (auto conf : config->getSubtreeList("curve")) + for (auto conf : config->getConfigSubtreeList("curve")) { //! \ogs_file_param{prj__curves__curve__name} - auto const name = conf.getParameter<std::string>("name"); + auto const name = conf.getConfigParameter<std::string>("name"); BaseLib::insertIfKeyUniqueElseError( _curves, name, diff --git a/Applications/ApplicationsLib/UncoupledProcessesTimeLoop.h b/Applications/ApplicationsLib/UncoupledProcessesTimeLoop.h index 7a830eb2a6aa5669357d778ab142e5500c76fd39..cc6e4f4c63211004c0776689f1e283d033ab26ff 100644 --- a/Applications/ApplicationsLib/UncoupledProcessesTimeLoop.h +++ b/Applications/ApplicationsLib/UncoupledProcessesTimeLoop.h @@ -232,12 +232,12 @@ std::unique_ptr<UncoupledProcessesTimeLoop<Matrix, Vector> > createUncoupledProcessesTimeLoop(BaseLib::ConfigTree const& conf) { //! \ogs_file_param{prj__time_stepping__type} - auto const type = conf.peekParameter<std::string>("type"); + auto const type = conf.peekConfigParameter<std::string>("type"); std::unique_ptr<NumLib::ITimeStepAlgorithm> timestepper; if (type == "SingleStep") { - conf.ignoreParameter("type"); + conf.ignoreConfigParameter("type"); timestepper.reset(new NumLib::FixedTimeStepping(0.0, 1.0, 1.0)); } else if (type == "FixedTimeStepping") { timestepper = NumLib::FixedTimeStepping::newInstance(conf); diff --git a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp index ed19652f2c5c5c20c9d65d33ec4a1657cbb4fb10..1a4e49badb210ffe30a3176b9b7981f4f6056b5c 100644 --- a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp @@ -237,7 +237,7 @@ MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() if (tg_mesh) { - std::vector<MeshLib::Node> tg_attr (lv.getAttributePoints()); + std::vector<MeshLib::Node> tg_attr (lv.getConfigAttributePoints()); FileIO::TetGenInterface tetgen_interface; tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, tg_attr); } diff --git a/BaseLib/ConfigTree-impl.h b/BaseLib/ConfigTree-impl.h index 21ddb0832bbf9d864699c68e1e47cf5f66e3729b..d14d78aa45a0a6e4546c28b9895c19ca0f5a2d4a 100644 --- a/BaseLib/ConfigTree-impl.h +++ b/BaseLib/ConfigTree-impl.h @@ -33,9 +33,9 @@ private: template<typename T> T ConfigTree:: -getParameter(std::string const& param) const +getConfigParameter(std::string const& param) const { - if (auto p = getParameterOptional<T>(param)) + if (auto p = getConfigParameterOptional<T>(param)) return *p; error("Key <" + param + "> has not been found"); @@ -44,37 +44,37 @@ getParameter(std::string const& param) const template<typename T> T ConfigTree:: -getParameter(std::string const& param, T const& default_value) const +getConfigParameter(std::string const& param, T const& default_value) const { - if (auto p = getParameterOptional<T>(param)) + if (auto p = getConfigParameterOptional<T>(param)) return *p; return default_value; } template <typename T> -boost::optional<T> ConfigTree::getParameterOptional( +boost::optional<T> ConfigTree::getConfigParameterOptional( std::string const& param) const { checkUnique(param); - return getParameterOptionalImpl(param, static_cast<T*>(nullptr)); + return getConfigParameterOptionalImpl(param, static_cast<T*>(nullptr)); } template <typename T> -boost::optional<T> ConfigTree::getParameterOptionalImpl( +boost::optional<T> ConfigTree::getConfigParameterOptionalImpl( std::string const& param, T*) const { - if (auto p = getSubtreeOptional(param)) return p->getValue<T>(); + if (auto p = getConfigSubtreeOptional(param)) return p->getValue<T>(); return boost::none; } template <typename T> -boost::optional<std::vector<T>> ConfigTree::getParameterOptionalImpl( +boost::optional<std::vector<T>> ConfigTree::getConfigParameterOptionalImpl( std::string const& param, std::vector<T>*) const { - if (auto p = getSubtreeOptional(param)) + if (auto p = getConfigSubtreeOptional(param)) { std::istringstream sstr{p->getValue<std::string>()}; std::vector<T> result; @@ -101,7 +101,7 @@ boost::optional<std::vector<T>> ConfigTree::getParameterOptionalImpl( template<typename T> Range<ConfigTree::ValueIterator<T> > ConfigTree:: -getParameterList(std::string const& param) const +getConfigParameterList(std::string const& param) const { checkUnique(param); markVisited<T>(param, Attr::TAG, true); @@ -115,7 +115,7 @@ getParameterList(std::string const& param) const template<typename T> T ConfigTree:: -peekParameter(std::string const& param) const +peekConfigParameter(std::string const& param) const { checkKeyname(param); @@ -134,9 +134,9 @@ peekParameter(std::string const& param) const template<typename T> void ConfigTree:: -checkParameter(std::string const& param, T const& value) const +checkConfigParameter(std::string const& param, T const& value) const { - if (getParameter<T>(param) != value) { + if (getConfigParameter<T>(param) != value) { error("The value of key <" + param + "> is not the expected one."); } } @@ -144,9 +144,9 @@ checkParameter(std::string const& param, T const& value) const template<typename Ch> void ConfigTree:: -checkParameter(std::string const& param, Ch const* value) const +checkConfigParameter(std::string const& param, Ch const* value) const { - if (getParameter<std::string>(param) != value) { + if (getConfigParameter<std::string>(param) != value) { error("The value of key <" + param + "> is not the expected one."); } } @@ -173,9 +173,9 @@ getValue() const template<typename T> T ConfigTree:: -getAttribute(std::string const& attr) const +getConfigAttribute(std::string const& attr) const { - if (auto a = getAttributeOptional<T>(attr)) + if (auto a = getConfigAttributeOptional<T>(attr)) return *a; error("Did not find XML attribute with name \"" + attr + "\"."); @@ -184,7 +184,7 @@ getAttribute(std::string const& attr) const template<typename T> boost::optional<T> ConfigTree:: -getAttributeOptional(std::string const& attr) const +getConfigAttributeOptional(std::string const& attr) const { checkUniqueAttr(attr); auto& ct = markVisited<T>(attr, Attr::ATTR, true); diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp index ab6c9a43b4a16f887c6733d0adf77c80baa41cb0..23b90e24d507169c3a2403568f18fa14ae57fc35 100644 --- a/BaseLib/ConfigTree.cpp +++ b/BaseLib/ConfigTree.cpp @@ -85,9 +85,29 @@ operator=(ConfigTree&& other) return *this; } +ConfigTree +ConfigTree:: +getConfigParameter(std::string const& root) const +{ + auto ct = getConfigSubtree(root); + if (ct.hasChildren()) + error("Requested parameter <" + root + "> actually is a subtree."); + return ct; +} + +boost::optional<ConfigTree> +ConfigTree:: +getConfigParameterOptional(std::string const& root) const +{ + auto ct = getConfigSubtreeOptional(root); + if (ct && ct->hasChildren()) + error("Requested parameter <" + root + "> actually is a subtree."); + return ct; +} + Range<ConfigTree::ParameterIterator> ConfigTree:: -getParameterList(const std::string ¶m) const +getConfigParameterList(const std::string ¶m) const { checkUnique(param); markVisited(param, Attr::TAG, true); @@ -101,9 +121,9 @@ getParameterList(const std::string ¶m) const ConfigTree ConfigTree:: -getSubtree(std::string const& root) const +getConfigSubtree(std::string const& root) const { - if (auto t = getSubtreeOptional(root)) { + if (auto t = getConfigSubtreeOptional(root)) { return std::move(*t); } else { error("Key <" + root + "> has not been found."); @@ -112,7 +132,7 @@ getSubtree(std::string const& root) const boost::optional<ConfigTree> ConfigTree:: -getSubtreeOptional(std::string const& root) const +getConfigSubtreeOptional(std::string const& root) const { checkUnique(root); @@ -127,7 +147,7 @@ getSubtreeOptional(std::string const& root) const Range<ConfigTree::SubtreeIterator> ConfigTree:: -getSubtreeList(std::string const& root) const +getConfigSubtreeList(std::string const& root) const { checkUnique(root); markVisited(root, Attr::TAG, true); @@ -139,7 +159,7 @@ getSubtreeList(std::string const& root) const SubtreeIterator(p.second, root, *this)); } -void ConfigTree::ignoreParameter(const std::string ¶m) const +void ConfigTree::ignoreConfigParameter(const std::string ¶m) const { checkUnique(param); // if not found, peek only @@ -147,7 +167,7 @@ void ConfigTree::ignoreParameter(const std::string ¶m) const markVisited(param, Attr::TAG, peek_only); } -void ConfigTree::ignoreAttribute(const std::string &attr) const +void ConfigTree::ignoreConfigAttribute(const std::string &attr) const { checkUniqueAttr(attr); @@ -158,7 +178,7 @@ void ConfigTree::ignoreAttribute(const std::string &attr) const markVisited(attr, Attr::ATTR, peek_only); } -void ConfigTree::ignoreParameterAll(const std::string ¶m) const +void ConfigTree::ignoreConfigParameterAll(const std::string ¶m) const { checkUnique(param); auto& ct = markVisited(param, Attr::TAG, true); diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h index 2a535f22b4072a4c2e7f86b43a83ec1bcdfd0416..179b79ec7c4623201f9d8eb221b058141369a16b 100644 --- a/BaseLib/ConfigTree.h +++ b/BaseLib/ConfigTree.h @@ -70,7 +70,7 @@ template<typename Iterator> class Range; * existing configuration parameters from the source code. * * This class maintains a read counter for each parameter accessed through any of its methods. - * Read counters are increased with every read (the only exception being the peekParameter() method). + * Read counters are increased with every read (the only exception being the peekConfigParameter() method). * The destructor finally decreases the read counter for every tag/attribute it find on the * current level of the XML tree. If the increases/decreases don't cancel each other, warning * messages are generated. This check can also be enforced before destruction by using the @@ -293,28 +293,28 @@ public: * \pre \c param must not have been read before from this ConfigTree. */ template<typename T> T - getParameter(std::string const& param) const; + getConfigParameter(std::string const& param) const; /*! Get parameter \c param of type \c T from the configuration tree or the \c default_value. * - * This method has a similar behaviour as getParameter(std::string const&) except in case + * This method has a similar behaviour as getConfigParameter(std::string const&) except in case * of errors the \c default_value is returned. * * \pre \c param must not have been read before from this ConfigTree. */ template<typename T> T - getParameter(std::string const& param, T const& default_value) const; + getConfigParameter(std::string const& param, T const& default_value) const; /*! Get parameter \c param of type \c T from the configuration tree if present * - * This method has a similar behaviour as getParameter(std::string const&) except + * This method has a similar behaviour as getConfigParameter(std::string const&) except * no errors are raised. Rather it can be told from the return value if the * parameter could be read. * * \pre \c param must not have been read before from this ConfigTree. */ template<typename T> boost::optional<T> - getParameterOptional(std::string const& param) const; + getConfigParameterOptional(std::string const& param) const; /*! Fetches all parameters with name \c param from the current level of the tree. * @@ -323,13 +323,13 @@ public: * \pre \c param must not have been read before from this ConfigTree. */ template<typename T> Range<ValueIterator<T> > - getParameterList(std::string const& param) const; + getConfigParameterList(std::string const& param) const; //!\} /*! \name Methods for accessing parameters that have attributes * - * The <tt>getParameter...()</tt> methods in this group---note: they do not have template + * The <tt>getConfigParameter...()</tt> methods in this group---note: they do not have template * parameters---check that the queried parameters do not have any children (apart from XML * attributes); if they do, error() is called. * @@ -338,6 +338,24 @@ public: */ //!\{ + /*! Get parameter \c param from the configuration tree. + * + * \return the subtree representing the requested parameter + * + * \pre \c param must not have been read before from this ConfigTree. + */ + ConfigTree + getConfigParameter(std::string const& param) const; + + /*! Get parameter \c param from the configuration tree if present. + * + * \return the subtree representing the requested parameter + * + * \pre \c param must not have been read before from this ConfigTree. + */ + boost::optional<ConfigTree> + getConfigParameterOptional(std::string const& param) const; + /*! Fetches all parameters with name \c param from the current level of the tree. * * The return value is suitable to be used with range-base for-loops. @@ -345,7 +363,7 @@ public: * \pre \c param must not have been read before from this ConfigTree. */ Range<ParameterIterator> - getParameterList(std::string const& param) const; + getConfigParameterList(std::string const& param) const; /*! Get the plain data contained in the current level of the tree. * @@ -363,7 +381,7 @@ public: * \pre \c param must not have been read before from this ConfigTree. */ template<typename T> T - getAttribute(std::string const& attr) const; + getConfigAttribute(std::string const& attr) const; /*! Get XML attribute \c attr of type \c T for the current parameter if present. * @@ -372,7 +390,7 @@ public: * \pre \c param must not have been read before from this ConfigTree. */ template<typename T> boost::optional<T> - getAttributeOptional(std::string const& attr) const; + getConfigAttributeOptional(std::string const& attr) const; //!\} @@ -392,21 +410,21 @@ public: * But in order that the requested parameter counts as "completely parsed", it has to be * read through some other method, too. * - * Return value and error behaviour are the same as for getParameter<T>(std::string const&). + * Return value and error behaviour are the same as for getConfigParameter<T>(std::string const&). */ template<typename T> T - peekParameter(std::string const& param) const; + peekConfigParameter(std::string const& param) const; /*! Assert that \c param has the given \c value. * - * Convenience method combining getParameter(std::string const&) with a check. + * Convenience method combining getConfigParameter(std::string const&) with a check. */ template<typename T> void - checkParameter(std::string const& param, T const& value) const; + checkConfigParameter(std::string const& param, T const& value) const; - //! Make checkParameter() work for string literals. + //! Make checkConfigParameter() work for string literals. template<typename Ch> void - checkParameter(std::string const& param, Ch const* value) const; + checkConfigParameter(std::string const& param, Ch const* value) const; //!\} @@ -422,14 +440,14 @@ public: * \pre \c root must not have been read before from this ConfigTree. */ ConfigTree - getSubtree(std::string const& root) const; + getConfigSubtree(std::string const& root) const; /*! Get the subtree rooted at \c root if present * * \pre \c root must not have been read before from this ConfigTree. */ boost::optional<ConfigTree> - getSubtreeOptional(std::string const& root) const; + getConfigSubtreeOptional(std::string const& root) const; /*! Get all subtrees that have a root \c root from the current level of the tree. * @@ -438,7 +456,7 @@ public: * \pre \c root must not have been read before from this ConfigTree. */ Range<SubtreeIterator> - getSubtreeList(std::string const& root) const; + getConfigSubtreeList(std::string const& root) const; //!\} @@ -453,7 +471,7 @@ public: * * \pre \c param must not have been read before from this ConfigTree. */ - void ignoreParameter(std::string const& param) const; + void ignoreConfigParameter(std::string const& param) const; /*! Tell this instance to ignore all parameters \c param on the current level of the tree. * @@ -461,7 +479,7 @@ public: * * \pre \c param must not have been read before from this ConfigTree. */ - void ignoreParameterAll(std::string const& param) const; + void ignoreConfigParameterAll(std::string const& param) const; /*! Tell this instance to ignore the XML attribute \c attr. * @@ -469,7 +487,7 @@ public: * * \pre \c attr must not have been read before from this ConfigTree. */ - void ignoreAttribute(std::string const& attr) const; + void ignoreConfigAttribute(std::string const& attr) const; //!\} @@ -490,11 +508,11 @@ public: private: //! Default implementation of reading a value of type T. template<typename T> boost::optional<T> - getParameterOptionalImpl(std::string const& param, T*) const; + getConfigParameterOptionalImpl(std::string const& param, T*) const; //! Implementation of reading a vector of values of type T. template<typename T> boost::optional<std::vector<T>> - getParameterOptionalImpl(std::string const& param, std::vector<T>*) const; + getConfigParameterOptionalImpl(std::string const& param, std::vector<T>*) const; private: struct CountType diff --git a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp index 2194d2d0cf65b09440f85f290e02a276d55914ae..26414cbb821954ecb459d45999b1527d7637feac 100644 --- a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp +++ b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp @@ -41,9 +41,9 @@ bool BoostXmlGmlInterface::readFile(const std::string &fname) auto doc = BaseLib::makeConfigTree(fname, true, "OpenGeoSysGLI"); // ignore attributes related to XML schema - doc->ignoreAttribute("xmlns:xsi"); - doc->ignoreAttribute("xsi:noNamespaceSchemaLocation"); - doc->ignoreAttribute("xmlns:ogs"); + doc->ignoreConfigAttribute("xmlns:xsi"); + doc->ignoreConfigAttribute("xsi:noNamespaceSchemaLocation"); + doc->ignoreConfigAttribute("xmlns:ogs"); auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( new std::vector<GeoLib::Point*>); @@ -58,7 +58,7 @@ bool BoostXmlGmlInterface::readFile(const std::string &fname) std::unique_ptr<MapNameId> sfc_names{new MapNameId}; //! \ogs_file_param{gml__name} - auto geo_name = doc->getParameter<std::string>("name"); + auto geo_name = doc->getConfigParameter<std::string>("name"); if (geo_name.empty()) { ERR("BoostXmlGmlInterface::readFile(): <name> tag is empty."); @@ -66,14 +66,14 @@ bool BoostXmlGmlInterface::readFile(const std::string &fname) } //! \ogs_file_param{gml__points} - for (auto st : doc->getSubtreeList("points")) + for (auto st : doc->getConfigSubtreeList("points")) { readPoints(st, *points, *pnt_names); _geo_objects.addPointVec(std::move(points), geo_name, pnt_names.release()); } //! \ogs_file_param{gml__polylines} - for (auto st : doc->getSubtreeList("polylines")) + for (auto st : doc->getConfigSubtreeList("polylines")) { readPolylines(st, *polylines, @@ -83,7 +83,7 @@ bool BoostXmlGmlInterface::readFile(const std::string &fname) } //! \ogs_file_param{gml__surfaces} - for (auto st : doc->getSubtreeList("surfaces")) + for (auto st : doc->getConfigSubtreeList("surfaces")) { readSurfaces(st, *surfaces, @@ -108,16 +108,16 @@ void BoostXmlGmlInterface::readPoints(BaseLib::ConfigTree const& pointsRoot, std::map<std::string, std::size_t>& pnt_names ) { //! \ogs_file_param{gml__points__point} - for (auto const pt : pointsRoot.getParameterList("point")) + for (auto const pt : pointsRoot.getConfigParameterList("point")) { //! \ogs_file_attr{gml__points__point__id} - auto const p_id = pt.getAttribute<std::size_t>("id"); + auto const p_id = pt.getConfigAttribute<std::size_t>("id"); //! \ogs_file_attr{gml__points__point__x} - auto const p_x = pt.getAttribute<double>("x"); + auto const p_x = pt.getConfigAttribute<double>("x"); //! \ogs_file_attr{gml__points__point__y} - auto const p_y = pt.getAttribute<double>("y"); + auto const p_y = pt.getConfigAttribute<double>("y"); //! \ogs_file_attr{gml__points__point__z} - auto const p_z = pt.getAttribute<double>("z"); + auto const p_z = pt.getConfigAttribute<double>("z"); auto const p_size = points.size(); BaseLib::insertIfKeyUniqueElseError(_idx_map, p_id, p_size, @@ -125,7 +125,7 @@ void BoostXmlGmlInterface::readPoints(BaseLib::ConfigTree const& pointsRoot, points.push_back(new GeoLib::Point(p_x, p_y, p_z, p_id)); //! \ogs_file_attr{gml__points__point__name} - if (auto const p_name = pt.getAttributeOptional<std::string>("name")) + if (auto const p_name = pt.getConfigAttributeOptional<std::string>("name")) { if (p_name->empty()) { ERR("Empty point name found in geometry file."); @@ -146,10 +146,10 @@ void BoostXmlGmlInterface::readPolylines( std::map<std::string, std::size_t>& ply_names) { //! \ogs_file_param{gml__polylines__polyline} - for (auto const pl : polylinesRoot.getSubtreeList("polyline")) + for (auto const pl : polylinesRoot.getConfigSubtreeList("polyline")) { //! \ogs_file_attr{gml__polylines__polyline__id} - auto const id = pl.getAttribute<std::size_t>("id"); + auto const id = pl.getConfigAttribute<std::size_t>("id"); // The id is not used but must be present in the GML file. // That's why pl.ignore...() cannot be used. (void) id; @@ -157,7 +157,7 @@ void BoostXmlGmlInterface::readPolylines( polylines.push_back(new GeoLib::Polyline(points)); //! \ogs_file_attr{gml__polylines__polyline__name} - if (auto const p_name = pl.getAttributeOptional<std::string>("name")) + if (auto const p_name = pl.getConfigAttributeOptional<std::string>("name")) { if (p_name->empty()) { ERR("Empty polyline name found in geometry file."); @@ -168,14 +168,14 @@ void BoostXmlGmlInterface::readPolylines( "The polyline name is not unique."); //! \ogs_file_param{gml__polylines__polyline__pnt} - for (auto const pt : pl.getParameterList<std::size_t>("pnt")) { + for (auto const pt : pl.getConfigParameterList<std::size_t>("pnt")) { polylines.back()->addPoint(pnt_id_map[_idx_map[pt]]); } } else { // polyline has no name, ignore it. - pl.ignoreParameterAll("pnt"); + pl.ignoreConfigParameterAll("pnt"); } } } @@ -188,17 +188,17 @@ void BoostXmlGmlInterface::readSurfaces( std::map<std::string, std::size_t>& sfc_names) { //! \ogs_file_param{gml__surfaces__surface} - for (auto const& sfc : surfacesRoot.getSubtreeList("surface")) + for (auto const& sfc : surfacesRoot.getConfigSubtreeList("surface")) { //! \ogs_file_attr{gml__surfaces__surface__id} - auto const id = sfc.getAttribute<std::size_t>("id"); + auto const id = sfc.getConfigAttribute<std::size_t>("id"); // The id is not used but must be present in the GML file. // That's why sfc.ignore...() cannot be used. (void) id; surfaces.push_back(new GeoLib::Surface(points)); //! \ogs_file_attr{gml__surfaces__surface__name} - if (auto const s_name = sfc.getAttributeOptional<std::string>("name")) + if (auto const s_name = sfc.getConfigAttributeOptional<std::string>("name")) { if (s_name->empty()) { ERR("Empty surface name found in geometry file."); @@ -209,13 +209,13 @@ void BoostXmlGmlInterface::readSurfaces( "The surface name is not unique."); //! \ogs_file_param{gml__surfaces__surface__element} - for (auto const& element : sfc.getParameterList("element")) { + for (auto const& element : sfc.getConfigParameterList("element")) { //! \ogs_file_attr{gml__surfaces__surface__element__p1} - auto const p1_attr = element.getAttribute<std::size_t>("p1"); + auto const p1_attr = element.getConfigAttribute<std::size_t>("p1"); //! \ogs_file_attr{gml__surfaces__surface__element__p2} - auto const p2_attr = element.getAttribute<std::size_t>("p2"); + auto const p2_attr = element.getConfigAttribute<std::size_t>("p2"); //! \ogs_file_attr{gml__surfaces__surface__element__p3} - auto const p3_attr = element.getAttribute<std::size_t>("p3"); + auto const p3_attr = element.getConfigAttribute<std::size_t>("p3"); auto const p1 = pnt_id_map[_idx_map[p1_attr]]; auto const p2 = pnt_id_map[_idx_map[p2_attr]]; @@ -226,7 +226,7 @@ void BoostXmlGmlInterface::readSurfaces( else { // surface has no name, ignore it. - sfc.ignoreParameterAll("element"); + sfc.ignoreConfigParameterAll("element"); } } } diff --git a/MaterialsLib/Adsorption/Reaction.cpp b/MaterialsLib/Adsorption/Reaction.cpp index 2db390d4cb445be864394a3c5c25eba56e82120a..b3195ff639cb92e3c52372912eb8e428ade7c168 100644 --- a/MaterialsLib/Adsorption/Reaction.cpp +++ b/MaterialsLib/Adsorption/Reaction.cpp @@ -33,7 +33,7 @@ Reaction:: newInstance(BaseLib::ConfigTree const& conf) { //! \ogs_file_param{materials__adsorption__reaction__type} - auto const type = conf.getParameter<std::string>("type"); + auto const type = conf.getConfigParameter<std::string>("type"); if (type == "Z13XBF") return std::unique_ptr<Reaction>(new DensityLegacy); diff --git a/MaterialsLib/Adsorption/ReactionCaOH2.h b/MaterialsLib/Adsorption/ReactionCaOH2.h index 8d1ecae8503426e5f0c224168f0894812ed83744..610284ac3dd48d50e286c9b0170b487a27a7b613 100644 --- a/MaterialsLib/Adsorption/ReactionCaOH2.h +++ b/MaterialsLib/Adsorption/ReactionCaOH2.h @@ -28,7 +28,7 @@ class ReactionCaOH2 final : public Reaction public: explicit ReactionCaOH2(BaseLib::ConfigTree const& conf) : //! \ogs_file_param{materials__adsorption__reaction__CaOH2__ode_solver_config} - _ode_solver_config{conf.getSubtree("ode_solver_config")} + _ode_solver_config{conf.getConfigSubtree("ode_solver_config")} {} double getEnthalpy(const double /*p_Ads*/, const double /*T_Ads*/, diff --git a/MaterialsLib/Adsorption/ReactionSinusoidal.h b/MaterialsLib/Adsorption/ReactionSinusoidal.h index d4b293ec47301275aad62a3983e8240595934c26..5dc5b6db58d661bb094d42c409c8259cb73f66a4 100644 --- a/MaterialsLib/Adsorption/ReactionSinusoidal.h +++ b/MaterialsLib/Adsorption/ReactionSinusoidal.h @@ -23,7 +23,7 @@ class ReactionSinusoidal final : public Reaction public: explicit ReactionSinusoidal(BaseLib::ConfigTree const& conf) : //! \ogs_file_param{materials__adsorption__reaction__Sinusoidal__reaction_enthalpy} - _enthalpy(conf.getParameter<double>("reaction_enthalpy")) + _enthalpy(conf.getConfigParameter<double>("reaction_enthalpy")) { } diff --git a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp index ba366d2acbe66dcf2f884c9d9d3c0937ada0f980..ffa51c70ca6c469c96b36c294bc381b42742ad81 100644 --- a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp +++ b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp @@ -144,24 +144,24 @@ void EigenLinearSolver::setOption(BaseLib::ConfigTree const& option) { ignoreOtherLinearSolvers(option, "eigen"); //! \ogs_file_param{linear_solver__eigen} - auto const ptSolver = option.getSubtreeOptional("eigen"); + auto const ptSolver = option.getConfigSubtreeOptional("eigen"); if (!ptSolver) return; //! \ogs_file_param{linear_solver__eigen__solver_type} - if (auto solver_type = ptSolver->getParameterOptional<std::string>("solver_type")) { + if (auto solver_type = ptSolver->getConfigParameterOptional<std::string>("solver_type")) { _option.solver_type = _option.getSolverType(*solver_type); } //! \ogs_file_param{linear_solver__eigen__precon_type} - if (auto precon_type = ptSolver->getParameterOptional<std::string>("precon_type")) { + if (auto precon_type = ptSolver->getConfigParameterOptional<std::string>("precon_type")) { _option.precon_type = _option.getPreconType(*precon_type); } //! \ogs_file_param{linear_solver__eigen__error_tolerance} - if (auto error_tolerance = ptSolver->getParameterOptional<double>("error_tolerance")) { + if (auto error_tolerance = ptSolver->getConfigParameterOptional<double>("error_tolerance")) { _option.error_tolerance = *error_tolerance; } //! \ogs_file_param{linear_solver__eigen__max_iteration_step} - if (auto max_iteration_step = ptSolver->getParameterOptional<int>("max_iteration_step")) { + if (auto max_iteration_step = ptSolver->getConfigParameterOptional<int>("max_iteration_step")) { _option.max_iterations = *max_iteration_step; } } diff --git a/MathLib/LinAlg/LinearSolverOptions.cpp b/MathLib/LinAlg/LinearSolverOptions.cpp index 52b22ad1c6f44dbe51e8fe36855feb8d9d3271c5..e15dd3357d4c530a1eeae88e2c1e1dd9cc02f2f8 100644 --- a/MathLib/LinAlg/LinearSolverOptions.cpp +++ b/MathLib/LinAlg/LinearSolverOptions.cpp @@ -18,7 +18,7 @@ ignoreOtherLinearSolvers(const BaseLib::ConfigTree &config, const std::string &solver_name) { for (auto const& s : known_linear_solvers) { - if (s!=solver_name) config.ignoreParameter(s); + if (s!=solver_name) config.ignoreConfigParameter(s); } } diff --git a/MathLib/LinAlg/Lis/LisOption.h b/MathLib/LinAlg/Lis/LisOption.h index 7c682d3cbd28f18ca421ce97ffbbdf13eccd64e8..db222b8ba163f5d9a4b980e5ac8f2e56ab84dc3f 100644 --- a/MathLib/LinAlg/Lis/LisOption.h +++ b/MathLib/LinAlg/Lis/LisOption.h @@ -45,7 +45,7 @@ struct LisOption if (options) { ignoreOtherLinearSolvers(*options, "lis"); //! \ogs_file_param{linear_solver__lis} - if (auto s = options->getParameterOptional<std::string>("lis")) { + if (auto s = options->getConfigParameterOptional<std::string>("lis")) { if (!s->empty()) { _option_string += " " + *s; INFO("Lis options: \"%s\"", _option_string.c_str()); diff --git a/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp b/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp index eac24fb9308d389a8134bb8024d3d7c3f5e1e0d5..59d0ba603712f55c16e823417c2e1498cef6e3c9 100644 --- a/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp +++ b/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp @@ -34,16 +34,16 @@ PETScLinearSolver::PETScLinearSolver(const std::string /*prefix*/, ignoreOtherLinearSolvers(*option, "petsc"); //! \ogs_file_param{linear_solver__petsc} - if (auto const subtree = option->getConfSubtreeOptional("petsc")) + if (auto const subtree = option->getConfigSubtreeOptional("petsc")) { if (auto const parameters = //! \ogs_file_param{linear_solver__petsc__parameters} - subtree->getParameterOptional<std::string>("parameters")) { + subtree->getConfigParameterOptional<std::string>("parameters")) { petsc_options = *parameters; } //! \ogs_file_param{linear_solver__petsc__prefix} - if (auto const pre = subtree->getParameterOptional<std::string>("prefix")) { + if (auto const pre = subtree->getConfigParameterOptional<std::string>("prefix")) { if (!pre->empty()) prefix = *pre + "_"; } diff --git a/MathLib/ODE/CVodeSolver.cpp b/MathLib/ODE/CVodeSolver.cpp index 4112f24dd200e251d3140b76e3034483f1deb69a..fbc060769dbc43bb77e399bad7c6268148596d33 100644 --- a/MathLib/ODE/CVodeSolver.cpp +++ b/MathLib/ODE/CVodeSolver.cpp @@ -134,7 +134,7 @@ CVodeSolverImpl::CVodeSolverImpl(const BaseLib::ConfigTree& config, { if (auto const param = //! \ogs_file_param{ode_solver__CVODE__linear_multistep_method} - config.getParameterOptional<std::string>("linear_multistep_method")) + config.getConfigParameterOptional<std::string>("linear_multistep_method")) { DBUG("setting linear multistep method (config: %s)", param->c_str()); @@ -155,7 +155,7 @@ CVodeSolverImpl::CVodeSolverImpl(const BaseLib::ConfigTree& config, if (auto const param = //! \ogs_file_param{ode_solver__CVODE__nonlinear_solver_iteration} - config.getParameterOptional<std::string>("nonlinear_solver_iteration")) + config.getConfigParameterOptional<std::string>("nonlinear_solver_iteration")) { DBUG("setting nonlinear solver iteration (config: %s)", param->c_str()); diff --git a/MeshLib/MeshGenerators/LayeredVolume.h b/MeshLib/MeshGenerators/LayeredVolume.h index fb0bd1b280c31f67efdca9f2ec6f4b08332dd217..1e58344e844af0ee719547db5e5986a412c482e1 100644 --- a/MeshLib/MeshGenerators/LayeredVolume.h +++ b/MeshLib/MeshGenerators/LayeredVolume.h @@ -49,7 +49,7 @@ public: double noDataReplacementValue = 0.0); /// Returns the region attribute vector necessary for assigning region attributes via TetGen - std::vector<MeshLib::Node> getAttributePoints() { return _attribute_points; } + std::vector<MeshLib::Node> getConfigAttributePoints() { return _attribute_points; } private: /// Adds another layer to the subsurface mesh diff --git a/NumLib/ODESolver/NonlinearSolver-impl.h b/NumLib/ODESolver/NonlinearSolver-impl.h index c37b46cf7981e05909093e0e90a13045dee9c494..c2a641ddd330da57b4353aca6882dfefc80406e2 100644 --- a/NumLib/ODESolver/NonlinearSolver-impl.h +++ b/NumLib/ODESolver/NonlinearSolver-impl.h @@ -263,11 +263,11 @@ createNonlinearSolver(MathLib::LinearSolver<Matrix, Vector>& linear_solver, using AbstractNLS = NonlinearSolverBase<Matrix, Vector>; //! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver__type} - auto const type = config.getParameter<std::string>("type"); + auto const type = config.getConfigParameter<std::string>("type"); //! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver__tol} - auto const tol = config.getParameter<double>("tol"); + auto const tol = config.getConfigParameter<double>("tol"); //! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver__max_iter} - auto const max_iter = config.getParameter<unsigned>("max_iter"); + auto const max_iter = config.getConfigParameter<unsigned>("max_iter"); if (type == "Picard") { diff --git a/NumLib/ODESolver/TimeDiscretizationBuilder.h b/NumLib/ODESolver/TimeDiscretizationBuilder.h index d7becec90b367dfb83cb07e8f208fa13916fba25..c3041c3a406892cb59bc0a43ba2163b43e846173 100644 --- a/NumLib/ODESolver/TimeDiscretizationBuilder.h +++ b/NumLib/ODESolver/TimeDiscretizationBuilder.h @@ -25,7 +25,7 @@ createTimeDiscretization(BaseLib::ConfigTree const& config) using T = std::unique_ptr<TimeDiscretization<Vector> >; //! \ogs_file_param{process__time_discretization__type} - auto const type = config.getParameter<std::string>("type"); + auto const type = config.getConfigParameter<std::string>("type"); if (type == "BackwardEuler") { using ConcreteTD = BackwardEuler<Vector>; @@ -35,12 +35,12 @@ createTimeDiscretization(BaseLib::ConfigTree const& config) return T(new ConcreteTD); } else if (type == "CrankNicolson") { //! \ogs_file_param{process__time_discretization__CrankNicolson__theta} - auto const theta = config.getParameter<double>("theta"); + auto const theta = config.getConfigParameter<double>("theta"); using ConcreteTD = CrankNicolson<Vector>; return T(new ConcreteTD(theta)); } else if (type == "BackwardDifferentiationFormula") { //! \ogs_file_param{process__time_discretization__BackwardDifferentiationFormula__order} - auto const order = config.getParameter<unsigned>("order"); + auto const order = config.getConfigParameter<unsigned>("order"); using ConcreteTD = BackwardDifferentiationFormula<Vector>; return T(new ConcreteTD(order)); } else { diff --git a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp index 430708381b04c23c7e66170446fa4ae810ae4409..1a9e082b7140ede18e191974325a90cda48868d2 100644 --- a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp +++ b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp @@ -36,14 +36,14 @@ std::unique_ptr<ITimeStepAlgorithm> FixedTimeStepping::newInstance(BaseLib::ConfigTree const& config) { //! \ogs_file_param{prj__time_stepping__type} - config.checkParameter("type", "FixedTimeStepping"); + config.checkConfigParameter("type", "FixedTimeStepping"); //! \ogs_file_param{prj__time_stepping__FixedTimeStepping__t_initial} - auto const t_initial = config.getParameter<double>("t_initial"); + auto const t_initial = config.getConfigParameter<double>("t_initial"); //! \ogs_file_param{prj__time_stepping__FixedTimeStepping__t_end} - auto const t_end = config.getParameter<double>("t_end"); + auto const t_end = config.getConfigParameter<double>("t_end"); //! \ogs_file_param{prj__time_stepping__FixedTimeStepping__timesteps} - auto const delta_ts = config.getSubtree("timesteps"); + auto const delta_ts = config.getConfigSubtree("timesteps"); std::vector<double> timesteps; double t_curr = t_initial; @@ -51,7 +51,7 @@ FixedTimeStepping::newInstance(BaseLib::ConfigTree const& config) // TODO: consider adding call "listNonEmpty" to config tree //! \ogs_file_param{prj__time_stepping__FixedTimeStepping__timesteps__pair} - auto const range = delta_ts.getSubtreeList("pair"); + auto const range = delta_ts.getConfigSubtreeList("pair"); if (range.begin() == range.end()) { ERR("no timesteps have been given"); std::abort(); @@ -59,9 +59,9 @@ FixedTimeStepping::newInstance(BaseLib::ConfigTree const& config) for (auto const pair : range) { //! \ogs_file_param{prj__time_stepping__FixedTimeStepping__timesteps__pair__repeat} - auto const repeat = pair.getParameter<std::size_t>("repeat"); + auto const repeat = pair.getConfigParameter<std::size_t>("repeat"); //! \ogs_file_param{prj__time_stepping__FixedTimeStepping__timesteps__pair__delta_t} - delta_t = pair.getParameter<double>("delta_t"); + delta_t = pair.getConfigParameter<double>("delta_t"); if (repeat == 0) { ERR("<repeat> is zero."); diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h index 52eb7e697c2f21f37741275acd7b248140ab3ffc..192767dc646fda305c7c0837ddbe21a6b03c69c3 100644 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h @@ -155,7 +155,7 @@ createGroundwaterFlowProcess( BaseLib::ConfigTree const& config) { //! \ogs_file_param{process__type} - config.checkParameter("type", "GROUNDWATER_FLOW"); + config.checkConfigParameter("type", "GROUNDWATER_FLOW"); DBUG("Create GroundwaterFlowProcess."); @@ -182,7 +182,7 @@ createGroundwaterFlowProcess( SecondaryVariableCollection<typename GlobalSetup::VectorType> secondary_variables { //! \ogs_file_param{process__secondary_variables} - config.getSubtreeOptional("secondary_variables"), + config.getConfigSubtreeOptional("secondary_variables"), { //! \ogs_file_param_special{process__GROUNDWATER_FLOW__secondary_variables__darcy_velocity_x} "darcy_velocity_x", @@ -195,7 +195,7 @@ createGroundwaterFlowProcess( ProcessOutput<typename GlobalSetup::VectorType> //! \ogs_file_param{process__output} - process_output{config.getSubtree("output"), + process_output{config.getConfigSubtree("output"), process_variables, secondary_variables}; return std::unique_ptr<GroundwaterFlowProcess<GlobalSetup>>{ diff --git a/ProcessLib/InitialCondition.cpp b/ProcessLib/InitialCondition.cpp index bad71cfb937979586946ade2a2bcbee0b7281290..fe57541b02074ee1d366c4ce601a237368b1dbce 100644 --- a/ProcessLib/InitialCondition.cpp +++ b/ProcessLib/InitialCondition.cpp @@ -24,10 +24,10 @@ std::unique_ptr<InitialCondition> createUniformInitialCondition( BaseLib::ConfigTree const& config, int const /*n_components*/) { //! \ogs_file_param{initial_condition__type} - config.checkParameter("type", "Uniform"); + config.checkConfigParameter("type", "Uniform"); //! \ogs_file_param{initial_condition__Uniform__value} - auto value = config.getParameter<double>("value"); + auto value = config.getConfigParameter<double>("value"); DBUG("Using value %g", value); return std::unique_ptr<InitialCondition>( @@ -40,10 +40,10 @@ std::unique_ptr<InitialCondition> createMeshPropertyInitialCondition( int const n_components) { //! \ogs_file_param{initial_condition__type} - config.checkParameter("type", "MeshProperty"); + config.checkConfigParameter("type", "MeshProperty"); //! \ogs_file_param{initial_condition__MeshProperty__field_name} - auto field_name = config.getParameter<std::string>("field_name"); + auto field_name = config.getConfigParameter<std::string>("field_name"); DBUG("Using field_name %s", field_name.c_str()); if (!mesh.getProperties().hasPropertyVector(field_name)) diff --git a/ProcessLib/NeumannBcConfig.h b/ProcessLib/NeumannBcConfig.h index 952da4c8d8df7771c16e5466363fbf2392ad4db9..c69ff159a36f9f523c57ad87c51990ad64ac2184 100644 --- a/ProcessLib/NeumannBcConfig.h +++ b/ProcessLib/NeumannBcConfig.h @@ -49,10 +49,10 @@ public: { DBUG("Constructing NeumannBcConfig from config."); //! \ogs_file_param{boundary_condition__type} - config.checkParameter("type", "UniformNeumann"); + config.checkConfigParameter("type", "UniformNeumann"); //! \ogs_file_param{boundary_condition__UniformNeumann__value} - double const value = config.getParameter<double>("value"); + double const value = config.getConfigParameter<double>("value"); DBUG("Using value %g", value); _function = new MathLib::ConstantFunction<double>(value); diff --git a/ProcessLib/Output.cpp b/ProcessLib/Output.cpp index 8a10358b9ebb9a2bebda43d35f6131ad3e9634f0..047f0871af5c0e97467b2fcc83d94b0e55b537d0 100644 --- a/ProcessLib/Output.cpp +++ b/ProcessLib/Output.cpp @@ -51,18 +51,18 @@ newInstance(const BaseLib::ConfigTree &config, std::string const& output_directo std::unique_ptr<Output> out{ new Output{ BaseLib::joinPaths(output_directory, //! \ogs_file_param{prj__output__prefix} - config.getParameter<std::string>("prefix"))}}; + config.getConfigParameter<std::string>("prefix"))}}; //! \ogs_file_param{prj__output__timesteps} - if (auto const timesteps = config.getSubtreeOptional("timesteps")) + if (auto const timesteps = config.getConfigSubtreeOptional("timesteps")) { //! \ogs_file_param{prj__output__timesteps__pair} - for (auto pair : timesteps->getSubtreeList("pair")) + for (auto pair : timesteps->getConfigSubtreeList("pair")) { //! \ogs_file_param{prj__output__timesteps__pair__repeat} - auto repeat = pair.getParameter<unsigned>("repeat"); + auto repeat = pair.getConfigParameter<unsigned>("repeat"); //! \ogs_file_param{prj__output__timesteps__pair__each_steps} - auto each_steps = pair.getParameter<unsigned>("each_steps"); + auto each_steps = pair.getConfigParameter<unsigned>("each_steps"); assert(repeat != 0 && each_steps != 0); out->_repeats_each_steps.emplace_back(repeat, each_steps); diff --git a/ProcessLib/Parameter.cpp b/ProcessLib/Parameter.cpp index 3a27f473a326347d49473930d5e612d6c75761cf..188aeda773c462ebfcc25c5a636efdb752786f3d 100644 --- a/ProcessLib/Parameter.cpp +++ b/ProcessLib/Parameter.cpp @@ -20,9 +20,9 @@ std::unique_ptr<ParameterBase> createConstParameter( BaseLib::ConfigTree const& config) { //! \ogs_file_param{parameter__type} - config.checkParameter("type", "Constant"); + config.checkConfigParameter("type", "Constant"); //! \ogs_file_param{parameter__Constant__value} - auto value = config.getParameter<double>("value"); + auto value = config.getConfigParameter<double>("value"); DBUG("Using value %g", value); return std::unique_ptr<ParameterBase>(new ConstParameter<double>(value)); @@ -32,9 +32,9 @@ std::unique_ptr<ParameterBase> createMeshPropertyParameter( BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh) { //! \ogs_file_param{parameter__type} - config.checkParameter("type", "MeshProperty"); + config.checkConfigParameter("type", "MeshProperty"); //! \ogs_file_param{parameter__MeshProperty__field_name} - auto field_name = config.getParameter<std::string>("field_name"); + auto field_name = config.getConfigParameter<std::string>("field_name"); DBUG("Using field_name %s", field_name.c_str()); if (!mesh.getProperties().hasPropertyVector(field_name)) diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp index b324c0af134d0eee3079e54207bca3626fdc7797..7d2ef70d7ce092a71f2ddadf1690cb48b155cda6 100644 --- a/ProcessLib/Process.cpp +++ b/ProcessLib/Process.cpp @@ -17,7 +17,7 @@ ProcessVariable& findProcessVariable( { // Find process variable name in process config. //! \ogs_file_special - std::string const name = pv_config.getParameter<std::string>(tag); + std::string const name = pv_config.getConfigParameter<std::string>(tag); // Find corresponding variable by name. auto variable = std::find_if(variables.cbegin(), variables.cend(), @@ -51,7 +51,7 @@ findProcessVariables( vars.reserve(tag_names.size()); //! \ogs_file_param{process__process_variables} - auto const pv_conf = process_config.getSubtree("process_variables"); + auto const pv_conf = process_config.getConfigSubtree("process_variables"); for (auto const& tag : tag_names) { vars.emplace_back(findProcessVariable(variables, pv_conf, tag)); diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index 8efd40712d8a3da52803b1dc1a017659e36c217f..728445c4d58391178f60f5f23f79f5717c94b086 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -373,7 +373,7 @@ Parameter<ParameterArgs...>& findParameter( { // Find parameter name in process config. //! \ogs_file_special - auto const name = process_config.getParameter<std::string>(tag); + auto const name = process_config.getConfigParameter<std::string>(tag); // Find corresponding parameter by name. auto const parameter_it = diff --git a/ProcessLib/ProcessOutput.h b/ProcessLib/ProcessOutput.h index fa62c38dd01ce01b73e0600a6b6b42448bb4c697..db6e8164c1bc9e0aedf0e7cfc6020c9e8d1b430b 100644 --- a/ProcessLib/ProcessOutput.h +++ b/ProcessLib/ProcessOutput.h @@ -28,10 +28,10 @@ struct ProcessOutput final SecondaryVariableCollection<GlobalVector> const& secondary_variables) { //! \ogs_file_param{process__output__variables} - auto const out_vars = output_config.getSubtree("variables"); + auto const out_vars = output_config.getConfigSubtree("variables"); //! \ogs_file_param{process__output__variables__variable} - for (auto out_var : out_vars.getParameterList<std::string>("variable")) + for (auto out_var : out_vars.getConfigParameterList<std::string>("variable")) { if (output_variables.find(out_var) != output_variables.cend()) { @@ -59,7 +59,7 @@ struct ProcessOutput final output_variables.insert(out_var); } - if (auto out_resid = output_config.getParameterOptional<bool>( + if (auto out_resid = output_config.getConfigParameterOptional<bool>( "output_extrapolation_residuals")) { output_residuals = *out_resid; } @@ -67,7 +67,7 @@ struct ProcessOutput final // debug output if (auto const param = //! \ogs_file_param{process__output__output_iteration_results} - output_config.getParameterOptional<bool>("output_iteration_results")) + output_config.getConfigParameterOptional<bool>("output_iteration_results")) { DBUG("output_iteration_results: %s", (*param) ? "true" : "false"); diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index eea4d4599f0338b0f5d43ad96624bb3bf5f09c72..b822875cb41bfca88f0ba5844d455376b665611b 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -23,19 +23,19 @@ ProcessVariable::ProcessVariable(BaseLib::ConfigTree const& config, GeoLib::GEOObjects const& geometries) : //! \ogs_file_param{prj__process_variables__process_variable__name} - _name(config.getParameter<std::string>("name")), + _name(config.getConfigParameter<std::string>("name")), _mesh(mesh), //! \ogs_file_param{prj__process_variables__process_variable__components} - _n_components(config.getParameter<int>("components")) + _n_components(config.getConfigParameter<int>("components")) { DBUG("Constructing process variable %s", this->_name.c_str()); // Initial condition //! \ogs_file_param{prj__process_variables__process_variable__initial_condition} - if (auto ic_config = config.getSubtreeOptional("initial_condition")) + if (auto ic_config = config.getConfigSubtreeOptional("initial_condition")) { //! \ogs_file_param{initial_condition__type} - auto const type = ic_config->peekParameter<std::string>("type"); + auto const type = ic_config->peekConfigParameter<std::string>("type"); if (type == "Uniform") { _initial_condition = @@ -58,18 +58,18 @@ ProcessVariable::ProcessVariable(BaseLib::ConfigTree const& config, // Boundary conditions //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions} - if (auto bcs_config = config.getSubtreeOptional("boundary_conditions")) + if (auto bcs_config = config.getConfigSubtreeOptional("boundary_conditions")) { for (auto bc_config : //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition} - bcs_config->getSubtreeList("boundary_condition")) + bcs_config->getConfigSubtreeList("boundary_condition")) { auto const geometrical_set_name = //! \ogs_file_param{boundary_condition__geometrical_set} - bc_config.getParameter<std::string>("geometrical_set"); + bc_config.getConfigParameter<std::string>("geometrical_set"); auto const geometry_name = //! \ogs_file_param{boundary_condition__geometry} - bc_config.getParameter<std::string>("geometry"); + bc_config.getConfigParameter<std::string>("geometry"); GeoLib::GeoObject const* const geometry = geometries.getGeoObject(geometrical_set_name, geometry_name); @@ -79,7 +79,7 @@ ProcessVariable::ProcessVariable(BaseLib::ConfigTree const& config, // Construct type dependent boundary condition //! \ogs_file_param{boundary_condition__type} - auto const type = bc_config.peekParameter<std::string>("type"); + auto const type = bc_config.peekConfigParameter<std::string>("type"); if (type == "UniformDirichlet") { @@ -102,7 +102,7 @@ ProcessVariable::ProcessVariable(BaseLib::ConfigTree const& config, } // Source Terms - config.ignoreParameter("source_terms"); + config.ignoreConfigParameter("source_terms"); } ProcessVariable::ProcessVariable(ProcessVariable&& other) diff --git a/ProcessLib/SecondaryVariable.h b/ProcessLib/SecondaryVariable.h index 3b8e4be3998db88a09f247a4b396399bbda121ba..24858a53f9086afe7570a2ef4f057b134b704ff0 100644 --- a/ProcessLib/SecondaryVariable.h +++ b/ProcessLib/SecondaryVariable.h @@ -116,7 +116,7 @@ public: // read which variables are defined in the config for (auto const& tag_name : tag_names) { //! \ogs_file_special - if (auto var_name = config->getParameterOptional<std::string>(tag_name)) + if (auto var_name = config->getConfigParameterOptional<std::string>(tag_name)) { // TODO check primary vars, too BaseLib::insertIfKeyValueUniqueElseError( diff --git a/ProcessLib/TES/TESProcess.cpp b/ProcessLib/TES/TESProcess.cpp index d3c82d4a153b34edc6fa82699dad16c7cec3b870..732f0ed637f119deb5a02d18e69aca7426ce9272 100644 --- a/ProcessLib/TES/TESProcess.cpp +++ b/ProcessLib/TES/TESProcess.cpp @@ -103,7 +103,7 @@ TESProcess<GlobalSetup>::TESProcess( for (auto const& p : params) { - if (auto const par = config.getParameterOptional<double>(p.first)) + if (auto const par = config.getConfigParameterOptional<double>(p.first)) { DBUG("setting parameter `%s' to value `%g'", p.first.c_str(), *par); @@ -121,7 +121,7 @@ TESProcess<GlobalSetup>::TESProcess( for (auto const& p : params) { - if (auto const par = config.getParameterOptional<double>(p.first)) + if (auto const par = config.getConfigParameterOptional<double>(p.first)) { INFO("setting parameter `%s' to value `%g'", p.first.c_str(), *par); @@ -132,7 +132,7 @@ TESProcess<GlobalSetup>::TESProcess( // permeability if (auto par = - config.getParameterOptional<double>("solid_hydraulic_permeability")) + config.getConfigParameterOptional<double>("solid_hydraulic_permeability")) { DBUG( "setting parameter `solid_hydraulic_permeability' to isotropic " @@ -145,11 +145,11 @@ TESProcess<GlobalSetup>::TESProcess( // reactive system _assembly_params.react_sys = Adsorption::AdsorptionReaction::newInstance( - config.getSubtree("reactive_system")); + config.getConfigSubtree("reactive_system")); // debug output if (auto const param = - config.getParameterOptional<bool>("output_element_matrices")) + config.getConfigParameterOptional<bool>("output_element_matrices")) { DBUG("output_element_matrices: %s", (*param) ? "true" : "false"); @@ -159,7 +159,7 @@ TESProcess<GlobalSetup>::TESProcess( // TODO somewhere else /* if (auto const param = - config.getParameterOptional<bool>("output_global_matrix")) + config.getConfigParameterOptional<bool>("output_global_matrix")) { DBUG("output_global_matrix: %s", (*param) ? "true" : "false"); diff --git a/ProcessLib/TES/TESProcess.h b/ProcessLib/TES/TESProcess.h index 59a483236ba744aa29d5eca999fca26597966592..03b2fe89aa557e49947d2c1660e8d59d130c3382 100644 --- a/ProcessLib/TES/TESProcess.h +++ b/ProcessLib/TES/TESProcess.h @@ -116,7 +116,7 @@ std::unique_ptr<TESProcess<GlobalSetup>> createTESProcess( std::vector<std::unique_ptr<ParameterBase>> const& /*parameters*/, BaseLib::ConfigTree const& config) { - config.checkParameter("type", "TES"); + config.checkConfigParameter("type", "TES"); DBUG("Create TESProcess."); @@ -126,14 +126,14 @@ std::unique_ptr<TESProcess<GlobalSetup>> createTESProcess( SecondaryVariableCollection<typename GlobalSetup::VectorType> secondary_variables{ - config.getSubtreeOptional("secondary_variables"), + config.getConfigSubtreeOptional("secondary_variables"), {"solid_density", "reaction_rate", "velocity_x", "velocity_y", "velocity_z", "loading", "reaction_damping_factor", "vapour_partial_pressure", "relative_humidity", "equilibrium_loading"}}; ProcessOutput<typename GlobalSetup::VectorType> process_output{ - config.getSubtree("output"), process_variables, + config.getConfigSubtree("output"), process_variables, secondary_variables}; return std::unique_ptr<TESProcess<GlobalSetup>>{new TESProcess<GlobalSetup>{ diff --git a/ProcessLib/UniformDirichletBoundaryCondition.h b/ProcessLib/UniformDirichletBoundaryCondition.h index 3ce8081e4a9b3c63fd4963d9cbff77977f5f765f..6ec846aa3faff9bde90ea749dc37aaae2431d96b 100644 --- a/ProcessLib/UniformDirichletBoundaryCondition.h +++ b/ProcessLib/UniformDirichletBoundaryCondition.h @@ -43,10 +43,10 @@ public: { DBUG("Constructing UniformDirichletBoundaryCondition from config."); //! \ogs_file_param{boundary_condition__type} - config.checkParameter("type", "UniformDirichlet"); + config.checkConfigParameter("type", "UniformDirichlet"); //! \ogs_file_param{boundary_condition__UniformDirichlet__value} - _value = config.getParameter<double>("value"); + _value = config.getConfigParameter<double>("value"); DBUG("Using value %g", _value); } diff --git a/Tests/BaseLib/TestConfigTree.cpp b/Tests/BaseLib/TestConfigTree.cpp index fa409636df920c35f37b88aed7cbe450636d0ab7..f8501d479dbbbfd83a3c2516706c9d665dce0c0d 100644 --- a/Tests/BaseLib/TestConfigTree.cpp +++ b/Tests/BaseLib/TestConfigTree.cpp @@ -126,108 +126,108 @@ TEST(BaseLibConfigTree, Get) { auto const conf = makeConfigTree(ptree, cbs); - EXPECT_EQ(5.6e-4, conf.getParameter<double>("double")); // read certain types + EXPECT_EQ(5.6e-4, conf.getConfigParameter<double>("double")); // read certain types EXPECT_ERR_WARN(cbs, false, false); - EXPECT_TRUE(conf.getParameter<bool>("bool")); + EXPECT_TRUE(conf.getConfigParameter<bool>("bool")); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_EQ(5, conf.getParameter<int>("int")); + EXPECT_EQ(5, conf.getConfigParameter<int>("int")); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_EQ(8, conf.getParameter<int>("intx", 8)); // reading with default value + EXPECT_EQ(8, conf.getConfigParameter<int>("intx", 8)); // reading with default value EXPECT_ERR_WARN(cbs, false, false); // Testing subtree { - auto sub = conf.getSubtree("sub"); + auto sub = conf.getConfigSubtree("sub"); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_EQ(6.1f, sub.getParameter<float>("float")); + EXPECT_EQ(6.1f, sub.getConfigParameter<float>("float")); EXPECT_ERR_WARN(cbs, false, false); - if (auto f2 = sub.getParameterOptional<float>("float2")) { // read optional value + if (auto f2 = sub.getConfigParameterOptional<float>("float2")) { // read optional value EXPECT_EQ(0.1f, *f2); } EXPECT_ERR_WARN(cbs, false, false); - auto f3 = sub.getParameterOptional<float>("float3"); // optional value not existent + auto f3 = sub.getConfigParameterOptional<float>("float3"); // optional value not existent ASSERT_FALSE(f3); EXPECT_ERR_WARN(cbs, false, false); - // Testing the getParameter...() (non-template) / getValue() combination + // Testing the getConfigParameter...() (non-template) / getValue() combination - auto bool1 = sub.getSubtree("bool1"); + auto bool1 = sub.getConfigSubtree("bool1"); EXPECT_ERR_WARN(cbs, false, false); EXPECT_FALSE(bool1.getValue<bool>()); EXPECT_ERR_WARN(cbs, false, false); EXPECT_ANY_THROW(bool1.getValue<bool>()); // getting data twice EXPECT_ERR_WARN(cbs, true, false); - if (auto bool2 = sub.getSubtreeOptional("bool2")) { + if (auto bool2 = sub.getConfigSubtreeOptional("bool2")) { EXPECT_ERR_WARN(cbs, false, false); EXPECT_FALSE(bool2->getValue<bool>()); } EXPECT_ERR_WARN(cbs, false, false); - if (auto bool3 = sub.getSubtreeOptional("bool3")) { + if (auto bool3 = sub.getConfigSubtreeOptional("bool3")) { EXPECT_ERR_WARN(cbs, false, false); EXPECT_ANY_THROW(bool3->getValue<bool>()); EXPECT_ERR_WARN(cbs, true, false); // error because of no data } EXPECT_ERR_WARN(cbs, false, false); - EXPECT_FALSE(sub.getSubtreeOptional("bool4")); // optional value not existent + EXPECT_FALSE(sub.getConfigSubtreeOptional("bool4")); // optional value not existent EXPECT_ERR_WARN(cbs, false, false); // Testing ignore - sub.ignoreParameter("ignored"); + sub.ignoreConfigParameter("ignored"); EXPECT_ERR_WARN(cbs, false, false); - sub.ignoreParameterAll("ignored2"); + sub.ignoreConfigParameterAll("ignored2"); EXPECT_ERR_WARN(cbs, false, false); - sub.ignoreParameterAll("ignored4"); // I can ignore nonexistent stuff + sub.ignoreConfigParameterAll("ignored4"); // I can ignore nonexistent stuff EXPECT_ERR_WARN(cbs, false, false); // I can not ignore stuff that I already read // this also makes sure that the subtree inherits the callbacks properly - EXPECT_ANY_THROW(sub.ignoreParameter("float")); + EXPECT_ANY_THROW(sub.ignoreConfigParameter("float")); EXPECT_ERR_WARN(cbs, true, false); } for (int i : {0, 1, 2}) { (void) i; - EXPECT_EQ("Y", conf.peekParameter<std::string>("x")); + EXPECT_EQ("Y", conf.peekConfigParameter<std::string>("x")); EXPECT_ERR_WARN(cbs, false, false); } - conf.checkParameter<std::string>("x", "Y"); + conf.checkConfigParameter<std::string>("x", "Y"); EXPECT_ERR_WARN(cbs, false, false); // Testing attributes { - auto z = conf.getSubtree("z"); + auto z = conf.getConfigSubtree("z"); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_EQ(0.5, z.getAttribute<double>("attr")); + EXPECT_EQ(0.5, z.getConfigAttribute<double>("attr")); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_ANY_THROW(z.getAttribute<double>("attr")); // getting attribute twice + EXPECT_ANY_THROW(z.getConfigAttribute<double>("attr")); // getting attribute twice EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(z.getAttribute<double>("not_an_attr")); // nonexistent attribute + EXPECT_ANY_THROW(z.getConfigAttribute<double>("not_an_attr")); // nonexistent attribute EXPECT_ERR_WARN(cbs, true, false); EXPECT_EQ(32.0, z.getValue<double>()); EXPECT_ERR_WARN(cbs, false, false); - auto const opt = z.getAttributeOptional<bool>("optattr"); + auto const opt = z.getConfigAttributeOptional<bool>("optattr"); EXPECT_TRUE(!!opt); EXPECT_FALSE(*opt); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_ANY_THROW(z.getAttributeOptional<bool>("optattr")); // getting attribute twice + EXPECT_ANY_THROW(z.getConfigAttributeOptional<bool>("optattr")); // getting attribute twice EXPECT_ERR_WARN(cbs, true, false); - EXPECT_FALSE(z.getAttributeOptional<bool>("also_not_an_attr")); // nonexisting attribute + EXPECT_FALSE(z.getConfigAttributeOptional<bool>("also_not_an_attr")); // nonexisting attribute EXPECT_ERR_WARN(cbs, false, false); } // Testing vector { - auto v = conf.getParameter<std::vector<int>>("vector"); + auto v = conf.getConfigParameter<std::vector<int>>("vector"); EXPECT_ERR_WARN(cbs, false, false); EXPECT_EQ(5u, v.size()); std::vector<int> expected_vector(5); @@ -235,10 +235,10 @@ TEST(BaseLibConfigTree, Get) EXPECT_TRUE(std::equal(expected_vector.begin(), expected_vector.end(), v.begin())); EXPECT_ANY_THROW( - conf.getParameter<std::vector<int>>("vector_bad1")); + conf.getConfigParameter<std::vector<int>>("vector_bad1")); EXPECT_ERR_WARN(cbs, true, false); EXPECT_ANY_THROW( - conf.getParameter<std::vector<int>>("vector_bad2")); + conf.getConfigParameter<std::vector<int>>("vector_bad2")); EXPECT_ERR_WARN(cbs, true, false); } EXPECT_ERR_WARN(cbs, false, false); @@ -262,20 +262,20 @@ TEST(BaseLibConfigTree, IncompleteParse) { auto const conf = makeConfigTree(ptree, cbs); - EXPECT_EQ(5.6, conf.getParameter<double>("double")); + EXPECT_EQ(5.6, conf.getConfigParameter<double>("double")); EXPECT_ERR_WARN(cbs, false, false); - conf.getSubtree("tag"); + conf.getConfigSubtree("tag"); EXPECT_ERR_WARN(cbs, false, true); // data of <tag> has not been read - EXPECT_EQ(1, conf.getParameter<int>("pt")); + EXPECT_EQ(1, conf.getConfigParameter<int>("pt")); EXPECT_ERR_WARN(cbs, false, true); // attribute "x" has not been read { - auto pt2 = conf.getSubtree("pt2"); - EXPECT_EQ(0.5, pt2.getAttribute<double>("x")); + auto pt2 = conf.getConfigSubtree("pt2"); + EXPECT_EQ(0.5, pt2.getConfigAttribute<double>("x")); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_EQ(1.0, pt2.getAttribute<double>("y")); + EXPECT_EQ(1.0, pt2.getConfigAttribute<double>("y")); EXPECT_ERR_WARN(cbs, false, false); BaseLib::checkAndInvalidate(pt2); @@ -305,7 +305,7 @@ TEST(BaseLibConfigTree, CheckRange) { // check that std::distance can be computed twice in a row - auto list = conf.getSubtreeList("val"); + auto list = conf.getConfigSubtreeList("val"); EXPECT_ERR_WARN(cbs, false, false); EXPECT_EQ(3, std::distance(list.begin(), list.end())); EXPECT_ERR_WARN(cbs, false, false); @@ -315,7 +315,7 @@ TEST(BaseLibConfigTree, CheckRange) { // check that std::distance can be computed twice in a row - auto list = conf.getParameterList<int>("int"); + auto list = conf.getConfigParameterList<int>("int"); EXPECT_ERR_WARN(cbs, false, false); EXPECT_EQ(3, std::distance(list.begin(), list.end())); EXPECT_ERR_WARN(cbs, false, false); @@ -342,7 +342,7 @@ TEST(BaseLibConfigTree, GetSubtreeList) { auto const conf = makeConfigTree(ptree, cbs); - for (auto p : conf.getSubtreeList("nonexistent_list")) + for (auto p : conf.getConfigSubtreeList("nonexistent_list")) { (void) p; FAIL() << "Expected empty list"; @@ -350,9 +350,9 @@ TEST(BaseLibConfigTree, GetSubtreeList) EXPECT_ERR_WARN(cbs, false, false); int i = 0; - for (auto ct : conf.getSubtreeList("val")) + for (auto ct : conf.getConfigSubtreeList("val")) { - EXPECT_EQ(i, ct.getParameter<int>("int")); + EXPECT_EQ(i, ct.getConfigParameter<int>("int")); EXPECT_ERR_WARN(cbs, false, false); ++i; } @@ -374,7 +374,7 @@ TEST(BaseLibConfigTree, GetParamList) { auto const conf = makeConfigTree(ptree, cbs); - for (auto p : conf.getParameterList("nonexistent_list")) + for (auto p : conf.getConfigParameterList("nonexistent_list")) { (void) p; FAIL() << "Expected empty list"; @@ -382,14 +382,14 @@ TEST(BaseLibConfigTree, GetParamList) EXPECT_ERR_WARN(cbs, false, false); int i = 0; - for (auto p : conf.getParameterList("int")) + for (auto p : conf.getConfigParameterList("int")) { EXPECT_EQ(i, p.getValue<int>()); EXPECT_ERR_WARN(cbs, false, false); ++i; } - for (auto p : conf.getParameterList("int2")) + for (auto p : conf.getConfigParameterList("int2")) { EXPECT_EQ(i, p.getValue<int>()); EXPECT_ERR_WARN(cbs, false, false); @@ -398,7 +398,7 @@ TEST(BaseLibConfigTree, GetParamList) EXPECT_ERR_WARN(cbs, false, true); // attribute "a" not read { - auto range = conf.getParameterList("int3"); + auto range = conf.getConfigParameterList("int3"); EXPECT_ERR_WARN(cbs, false, false); EXPECT_ANY_THROW(*range.begin()); @@ -425,7 +425,7 @@ TEST(BaseLibConfigTree, GetValueList) { auto const conf = makeConfigTree(ptree, cbs); - for (auto p : conf.getParameterList<int>("nonexistent_list")) + for (auto p : conf.getConfigParameterList<int>("nonexistent_list")) { (void) p; FAIL() << "Expected empty list"; @@ -433,7 +433,7 @@ TEST(BaseLibConfigTree, GetValueList) EXPECT_ERR_WARN(cbs, false, false); int n = 0; - for (auto i : conf.getParameterList<int>("int")) + for (auto i : conf.getConfigParameterList<int>("int")) { EXPECT_EQ(n, i); EXPECT_ERR_WARN(cbs, false, false); @@ -460,39 +460,39 @@ TEST(BaseLibConfigTree, NoConversion) { auto const conf = makeConfigTree(ptree, cbs); - EXPECT_ANY_THROW(conf.getParameter<int>("int")); + EXPECT_ANY_THROW(conf.getConfigParameter<int>("int")); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.ignoreParameter("int")); // after failure I also cannot ignore something + EXPECT_ANY_THROW(conf.ignoreConfigParameter("int")); // after failure I also cannot ignore something EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.getParameter<double>("double")); + EXPECT_ANY_THROW(conf.getConfigParameter<double>("double")); EXPECT_ERR_WARN(cbs, true, false); // peek value existent but not convertible - EXPECT_ANY_THROW(conf.peekParameter<double>("non_double")); + EXPECT_ANY_THROW(conf.peekConfigParameter<double>("non_double")); EXPECT_ERR_WARN(cbs, true, false); // optional value existent but not convertible EXPECT_ANY_THROW( - auto d = conf.getParameterOptional<double>("non_double"); + auto d = conf.getConfigParameterOptional<double>("non_double"); ASSERT_FALSE(d); ); EXPECT_ERR_WARN(cbs, true, false); // assert that I can only ignore something once - conf.ignoreParameter("ign"); + conf.ignoreConfigParameter("ign"); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_ANY_THROW(conf.ignoreParameter("ign")); + EXPECT_ANY_THROW(conf.ignoreConfigParameter("ign")); EXPECT_ERR_WARN(cbs, true, false); - conf.ignoreParameterAll("ign2"); + conf.ignoreConfigParameterAll("ign2"); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_ANY_THROW(conf.ignoreParameterAll("ign2")); + EXPECT_ANY_THROW(conf.ignoreConfigParameterAll("ign2")); EXPECT_ERR_WARN(cbs, true, false); // assert that I cannot read a parameter twice - conf.getParameter<bool>("bool"); + conf.getConfigParameter<bool>("bool"); EXPECT_ERR_WARN(cbs, false, false); - EXPECT_ANY_THROW(conf.getParameter<bool>("bool")); + EXPECT_ANY_THROW(conf.getConfigParameter<bool>("bool")); EXPECT_ERR_WARN(cbs, true, false); } // ConfigTree destroyed here @@ -514,28 +514,28 @@ TEST(BaseLibConfigTree, BadKeynames) for (auto tag : { "<", "Z", ".", "$", "0", "", "/", "_", "a__" }) { - EXPECT_ANY_THROW(conf.getParameter<int>(tag)); + EXPECT_ANY_THROW(conf.getConfigParameter<int>(tag)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.getParameter<int>(tag, 500)); + EXPECT_ANY_THROW(conf.getConfigParameter<int>(tag, 500)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.getParameterOptional<int>(tag)); + EXPECT_ANY_THROW(conf.getConfigParameterOptional<int>(tag)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.getParameterList<int>(tag)); + EXPECT_ANY_THROW(conf.getConfigParameterList<int>(tag)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.peekParameter<int>(tag)); + EXPECT_ANY_THROW(conf.peekConfigParameter<int>(tag)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.checkParameter<int>(tag, 500)); + EXPECT_ANY_THROW(conf.checkConfigParameter<int>(tag, 500)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.getSubtree(tag)); + EXPECT_ANY_THROW(conf.getConfigSubtree(tag)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.getSubtreeOptional(tag)); + EXPECT_ANY_THROW(conf.getConfigSubtreeOptional(tag)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.getSubtreeList(tag)); + EXPECT_ANY_THROW(conf.getConfigSubtreeList(tag)); EXPECT_ERR_WARN(cbs, true, false); - EXPECT_ANY_THROW(conf.getAttribute<int>(tag)); + EXPECT_ANY_THROW(conf.getConfigAttribute<int>(tag)); EXPECT_ERR_WARN(cbs, true, false); } @@ -556,14 +556,14 @@ TEST(BaseLibConfigTree, StringLiterals) { auto const conf = makeConfigTree(ptree, cbs); - EXPECT_EQ("test", conf.getParameter<std::string>("s", "XX")); + EXPECT_EQ("test", conf.getConfigParameter<std::string>("s", "XX")); EXPECT_ERR_WARN(cbs, false, false); // <n> not present in the XML, so return the default value - EXPECT_EQ("XX", conf.getParameter<std::string>("n", "XX")); + EXPECT_EQ("XX", conf.getConfigParameter<std::string>("n", "XX")); EXPECT_ERR_WARN(cbs, false, false); - conf.checkParameter("t", "Test"); + conf.checkConfigParameter("t", "Test"); EXPECT_ERR_WARN(cbs, false, false); } // ConfigTree destroyed here EXPECT_ERR_WARN(cbs, false, false); @@ -582,10 +582,10 @@ TEST(BaseLibConfigTree, MoveConstruct) { auto conf = makeConfigTree(ptree, cbs); - EXPECT_EQ("test", conf.getParameter<std::string>("s", "XX")); + EXPECT_EQ("test", conf.getConfigParameter<std::string>("s", "XX")); EXPECT_ERR_WARN(cbs, false, false); - auto u = conf.getSubtree("u"); + auto u = conf.getConfigSubtree("u"); EXPECT_ERR_WARN(cbs, false, false); EXPECT_EQ("data", u.getValue<std::string>()); @@ -601,10 +601,10 @@ TEST(BaseLibConfigTree, MoveConstruct) // test that read status of children is transferred in move construction BaseLib::ConfigTree conf2(std::move(conf)); - EXPECT_EQ("XX", conf2.getParameter<std::string>("n", "XX")); + EXPECT_EQ("XX", conf2.getConfigParameter<std::string>("n", "XX")); EXPECT_ERR_WARN(cbs, false, false); - conf2.checkParameter("t", "Test"); + conf2.checkConfigParameter("t", "Test"); EXPECT_ERR_WARN(cbs, false, false); BaseLib::checkAndInvalidate(conf2); @@ -626,10 +626,10 @@ TEST(BaseLibConfigTree, MoveAssign) { auto conf = makeConfigTree(ptree, cbs); - EXPECT_EQ("test", conf.getParameter<std::string>("s", "XX")); + EXPECT_EQ("test", conf.getConfigParameter<std::string>("s", "XX")); EXPECT_ERR_WARN(cbs, false, false); - auto u = conf.getSubtree("u"); + auto u = conf.getConfigSubtree("u"); EXPECT_ERR_WARN(cbs, false, false); EXPECT_EQ("data", u.getValue<std::string>()); @@ -653,10 +653,10 @@ TEST(BaseLibConfigTree, MoveAssign) // entirely before assignment. EXPECT_ERR_WARN(cbs, false, true); - EXPECT_EQ("XX", conf2.getParameter<std::string>("n", "XX")); + EXPECT_EQ("XX", conf2.getConfigParameter<std::string>("n", "XX")); EXPECT_ERR_WARN(cbs, false, false); - conf2.checkParameter("t", "Test"); + conf2.checkConfigParameter("t", "Test"); EXPECT_ERR_WARN(cbs, false, false); } EXPECT_ERR_WARN(cbs, false, false); diff --git a/scripts/doc/get-project-params.sh b/scripts/doc/get-project-params.sh index 4068cb5c417ab0b06b1cf298ac3ea8bbcf4a8980..ce3af664582a59a93abe6fd24bb7db27662b44ab 100755 --- a/scripts/doc/get-project-params.sh +++ b/scripts/doc/get-project-params.sh @@ -27,13 +27,13 @@ cat <<"EOF" \ ^\s*//! \\ogs_file_\(param\|attr\){[A-Za-z_0-9]\+}\( \\todo .*\)\?$ ^\s*//! \\ogs_file_special$ ^\s*//! \\ogs_file_\(param\|attr\)_special{[A-Za-z_0-9]\+}\( \\todo .*\)\?$ -checkParameter.*) -getAttribute.*) -getParameter.*) -getSubtree.*) -ignoreAttribute.*) -ignoreParameter.*) -peekParameter.*) +checkConfigParameter.*) +getConfigAttribute.*) +getConfigParameter.*) +getConfigSubtree.*) +ignoreConfigAttribute.*) +ignoreConfigParameter.*) +peekConfigParameter.*) EOF # format as table: