From c4a9f983b2d4530cba3193e00e2f40976e45d766 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Wed, 19 Jul 2017 20:53:48 +0200 Subject: [PATCH] Removed patterns_tools.cc and refactored add_parameter --- include/deal.II/base/patterns_tools.h | 20 ++++++++- source/base/CMakeLists.txt | 1 - source/base/patterns_tools.cc | 64 --------------------------- 3 files changed, 18 insertions(+), 67 deletions(-) delete mode 100644 source/base/patterns_tools.cc diff --git a/include/deal.II/base/patterns_tools.h b/include/deal.II/base/patterns_tools.h index 584a18ca7e..23b51d1a49 100644 --- a/include/deal.II/base/patterns_tools.h +++ b/include/deal.II/base/patterns_tools.h @@ -18,14 +18,14 @@ #include +#include #include #include #include +#include #include #include -#include - #include #include @@ -148,6 +148,22 @@ namespace PatternsTools const std::unique_ptr &p = Convert::to_pattern()) = delete; }; + /** + * Declare a new entry in @p prm with name @p entry, set its default value + * to the content of the variable @p parameter, and create an action + * that will fill @p parameter with updated values when a file is parsed, + * or the entry is set to a new value. + * + * By default, the pattern to use is obtained by calling the function + * PatternsTools::Convert::to_pattern(), but a custom one can be used. + */ + template + void add_parameter(const std::string &entry, + ParameterType ¶meter, + ParameterHandler &prm, + const std::string &documentation = std::string(), + const Patterns::PatternBase &pattern = *Convert::to_pattern()); + /** * @addtogroup Exceptions * @{ diff --git a/source/base/CMakeLists.txt b/source/base/CMakeLists.txt index 434cec8d73..4625cb7418 100644 --- a/source/base/CMakeLists.txt +++ b/source/base/CMakeLists.txt @@ -45,7 +45,6 @@ SET(_src parsed_function.cc partitioner.cc path_search.cc - patterns_tools.cc polynomial.cc polynomials_abf.cc polynomials_adini.cc diff --git a/source/base/patterns_tools.cc b/source/base/patterns_tools.cc deleted file mode 100644 index c7340bb4d9..0000000000 --- a/source/base/patterns_tools.cc +++ /dev/null @@ -1,64 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 1998 - 2017 by the deal.II authors -// -// This file is part of the deal.II library. -// -// The deal.II library is free software; you can use it, redistribute -// it, and/or modify it under the terms of the GNU Lesser General -// Public License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// The full text of the license can be found in the file LICENSE at -// the top level of the deal.II distribution. -// -// --------------------------------------------------------------------- - - -#include -#include -#include -#include -#include - -DEAL_II_DISABLE_EXTRA_DIAGNOSTICS -#include -DEAL_II_ENABLE_EXTRA_DIAGNOSTICS - -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include - - -DEAL_II_NAMESPACE_OPEN - - - -//TODO[WB]: various functions here could be simplified by using namespace Utilities - -namespace PatternsTools -{ - std::string default_list_separator(unsigned int rank) - { - static std::array seps = {{" ", "," , ";" , "|" , "%"}}; - AssertThrow(rank < seps.size(), ExcMessage("I don't know what to use for such " - "high rank. Bailing out.")); - return seps[rank]; - } - - - std::string default_map_separator(unsigned int rank) - { - static std::array seps = {{" ", ":" , "=" , "@" , "#"}}; - AssertThrow(rank < seps.size(), ExcMessage("I don't know what to use for such " - "high rank. Bailing out.")); - return seps[rank]; - } -} - -DEAL_II_NAMESPACE_CLOSE -- 2.39.5