16 #ifndef dealii_parameter_handler_h 17 #define dealii_parameter_handler_h 26 #include <boost/archive/basic_archive.hpp> 27 #include <boost/property_tree/ptree_fwd.hpp> 28 #include <boost/property_tree/ptree_serialization.hpp> 29 #include <boost/serialization/split_member.hpp> 1018 const std::string &filename =
"input file",
1019 const std::string &last_line =
"",
1020 const bool skip_undefined =
false);
1045 const std::string &last_line =
"",
1046 const bool skip_undefined =
false,
1047 const bool assert_mandatory_entries_are_found =
false);
1059 const std::string &last_line =
"",
1060 const bool skip_undefined =
false);
1116 const std::string & default_value,
1118 const std::string & documentation =
"",
1119 const bool has_to_be_set =
false);
1166 const std::function<
void(
const std::string &
value)> &action);
1183 template <
class ParameterType>
1186 ParameterType & parameter,
1187 const std::string & documentation =
"",
1190 const bool has_to_be_set =
false);
1237 const std::string &alias_name,
1238 const bool alias_is_deprecated =
false);
1266 get(
const std::string &entry_string)
const;
1279 get(
const std::vector<std::string> &entry_subsection_path,
1280 const std::string & entry_string)
const;
1288 get_integer(
const std::string &entry_string)
const;
1299 get_integer(
const std::vector<std::string> &entry_subsection_path,
1300 const std::string & entry_string)
const;
1306 get_double(
const std::string &entry_name)
const;
1315 get_double(
const std::vector<std::string> &entry_subsection_path,
1316 const std::string & entry_string)
const;
1323 get_bool(
const std::string &entry_name)
const;
1334 get_bool(
const std::vector<std::string> &entry_subsection_path,
1335 const std::string & entry_string)
const;
1347 set(
const std::string &entry_name,
const std::string &new_value);
1360 set(
const std::string &entry_name,
const char *new_value);
1372 set(
const std::string &entry_name,
const long int new_value);
1388 set(
const std::string &entry_name,
const double new_value);
1400 set(
const std::string &entry_name,
const bool new_value);
1553 template <
class Archive>
1555 save(Archive &ar,
const unsigned int version)
const;
1561 template <
class Archive>
1563 load(Archive &ar,
const unsigned int version);
1570 template <
class Archive>
1572 serialize(Archive &archive,
const unsigned int version);
1576 BOOST_SERIALIZATION_SPLIT_MEMBER()
1593 std::set<std::string>
1614 <<
"The following entry already exists: " << arg1 <<
".");
1621 <<
"The string <" << arg1
1622 <<
"> does not match the given pattern <" << arg2 <<
">.");
1628 "You can't leave a subsection if you are already at the top level " 1629 "of the subsection hierarchy.");
1635 <<
"You can't ask for entry <" << arg1
1636 <<
"> you have not yet declared.");
1647 <<
"There are unequal numbers of 'subsection' and 'end' " 1648 "statements in the parameter file <" 1649 << arg1 <<
">." << (arg2.size() > 0 ?
"\n" + arg2 :
""));
1659 <<
"Line <" << arg1 <<
"> of file <" << arg2
1661 "no such subsection to be entered: " 1673 <<
"Line <" << arg1 <<
"> of file <" << arg2 <<
">: " << arg3);
1686 <<
"Line <" << arg1 <<
"> of file <" << arg2
1688 " The entry value \n" 1689 <<
" " << arg3 <<
'\n' 1690 <<
" for the entry named\n" 1691 <<
" " << arg4 <<
'\n' 1692 <<
" does not match the given pattern:\n" 1701 "The provided file could not be parsed as a " 1702 "ParameterHandler description.");
1725 <<
"Line <" << arg1 <<
"> of file <" << arg2
1727 "contains an 'include' or 'INCLUDE' statement, but the given " 1729 << arg3 <<
"> cannot be opened.");
1753 std::unique_ptr<boost::property_tree::ptree>
entries;
1770 std::vector<std::unique_ptr<const Patterns::PatternBase>>
patterns;
1778 std::vector<std::function<void(const std::string &)>>
actions;
1804 const std::string & name)
const;
1826 const std::string &input_filename,
1827 const unsigned int current_line_n,
1828 const bool skip_undefined);
1843 const boost::property_tree::ptree & tree,
1844 const std::vector<std::string> & target_subsection_path,
1846 const unsigned int indent_level,
1847 std::ostream & out)
const;
1864 static_cast<unsigned int>(f1) | static_cast<unsigned int>(f2));
2104 create_new(
const unsigned int run_no) = 0;
2147 const std::string &filename =
"input file",
2148 const std::string &last_line =
"",
2149 const bool skip_undefined =
false)
override;
2209 Entry(
const std::vector<std::string> &Path,
2210 const std::string & Name,
2211 const std::string & Value);
2217 split_different_values();
2277 init_branches_current_section();
2283 fill_entry_values(
const unsigned int run_no);
2288 template <
class Archive>
2298 std::vector<std::string> descriptions;
2300 for (
const auto &pattern :
patterns)
2301 descriptions.push_back(pattern->description());
2307 template <
class Archive>
2317 std::vector<std::string> descriptions;
2321 for (
const auto &description : descriptions)
2326 template <
class ParameterType>
2329 ParameterType & parameter,
2330 const std::string & documentation,
2332 const bool has_to_be_set)
2335 "You tried to add a parameter using a type " 2336 "that is const. Use a non-const type.");
2340 parameter, pattern.
clone()),
2346 const unsigned int pattern_index =
2349 auto action = [&, pattern_index](
const std::string &val) {
2351 val,
patterns[pattern_index]->clone());
std::vector< Entry > multiple_choices
long int get_integer(const std::string &entry_string) const
void loop(ITERATOR begin, typename identity< ITERATOR >::type end, DOFINFO &dinfo, INFOBOX &info, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
static const char path_separator
#define DeclException2(Exception2, type1, type2, outsequence)
static ::ExceptionBase & ExcEntryAlreadyExists(std::string arg1)
void assert_that_entries_have_been_set() const
static ::ExceptionBase & ExcCannotOpenIncludeStatementFile(int arg1, std::string arg2, std::string arg3)
std::string get_current_path() const
static ::ExceptionBase & ExcEntryUndeclared(std::string arg1)
friend class MultipleParameterLoop
static ::ExceptionBase & ExcUnbalancedSubsections(std::string arg1, std::string arg2)
std::ostream & print_parameters(std::ostream &out, const OutputStyle style) const
virtual void parse_input_from_string(const std::string &s, const std::string &last_line="", const bool skip_undefined=false)
virtual std::unique_ptr< PatternBase > clone() const =0
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern(), const bool has_to_be_set=false)
void log_parameters(LogStream &out, const OutputStyle style=DefaultStyle)
std::vector< std::string > subsection_path
#define DeclException5( Exception5, type1, type2, type3, type4, type5, outsequence)
void scan_line(std::string line, const std::string &input_filename, const unsigned int current_line_n, const bool skip_undefined)
static ::ExceptionBase & ExcValueDoesNotMatchPattern(std::string arg1, std::string arg2)
void load(Archive &ar, const unsigned int version)
std::vector< std::string > subsection_path
bool subsection_path_exists(const std::vector< std::string > &sub_path) const
void enter_subsection(const std::string &subsection)
static ::ExceptionBase & ExcInvalidXMLParameterFile()
static ::ExceptionBase & ExcCannotParseLine(int arg1, std::string arg2, std::string arg3)
double get_double(const std::string &entry_name) const
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation="", const bool has_to_be_set=false)
#define DeclException1(Exception1, type1, outsequence)
virtual void parse_input_from_xml(std::istream &input, const bool skip_undefined=false)
std::string get_current_full_path(const std::string &name) const
#define DeclExceptionMsg(Exception, defaulttext)
#define DEAL_II_NAMESPACE_CLOSE
std::unique_ptr< boost::property_tree::ptree > entries
virtual void parse_input(std::istream &input, const std::string &filename="input file", const std::string &last_line="", const bool skip_undefined=false)
std::unique_ptr< PatternBase > pattern_factory(const std::string &description)
bool get_bool(const std::string &entry_name) const
static ::ExceptionBase & ExcAlreadyAtTopLevel()
std::vector< std::unique_ptr< const Patterns::PatternBase > > patterns
bool operator==(const ParameterHandler &prm2) const
void log_parameters_section(LogStream &out, const OutputStyle style=DefaultStyle)
virtual void parse_input_from_json(std::istream &input, const bool skip_undefined=false)
std::set< std::string > get_entries_wrongly_not_set() const
ParameterHandler::OutputStyle operator|(const ParameterHandler::OutputStyle f1, const ParameterHandler::OutputStyle f2)
void add_action(const std::string &entry, const std::function< void(const std::string &value)> &action)
#define DEAL_II_NAMESPACE_OPEN
void save(Archive &ar, const unsigned int version) const
void run(const std::vector< std::vector< Iterator >> &colored_iterators, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length=2 *MultithreadInfo::n_threads(), const unsigned int chunk_size=8)
std::vector< std::string > different_values
#define DeclException3(Exception3, type1, type2, type3, outsequence)
std::size_t memory_consumption() const
static ::ExceptionBase & ExcInvalidEntryForPattern(int arg1, std::string arg2, std::string arg3, std::string arg4, std::string arg5)
void serialize(Archive &archive, const unsigned int version)
void recursively_print_parameters(const boost::property_tree::ptree &tree, const std::vector< std::string > &target_subsection_path, const ParameterHandler::OutputStyle style, const unsigned int indent_level, std::ostream &out) const
std::vector< std::function< void(const std::string &)> > actions
virtual ~ParameterHandler() override=default
static ::ExceptionBase & ExcNoSubsection(int arg1, std::string arg2, std::string arg3)
#define DEAL_II_DEPRECATED
void declare_alias(const std::string &existing_entry_name, const std::string &alias_name, const bool alias_is_deprecated=false)
std::map< std::string, std::pair< bool, bool > > entries_set_status
ExcValueDoesNotMatchPattern ExcInvalidEntryForPatternXML
ParameterHandler & operator=(const ParameterHandler &)=delete