Reference documentation for deal.II version GIT relicensing-12-g89ba5bf9db 2024-02-24 00:00:03+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
parameter_acceptor.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2017 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_base_parameter_acceptor_h
16#define dealii_base_parameter_acceptor_h
17
18#include <deal.II/base/config.h>
19
24
25#include <boost/signals2/signal.hpp>
26
27#include <mutex>
28#include <typeinfo>
29
31
33
34namespace internal
35{
40 struct ParameterAcceptorCompare;
41} // namespace internal
42
360{
361public:
368 ParameterAcceptor(const std::string &section_name = "");
369
373 unsigned int
374 get_acceptor_id() const;
375
379 virtual ~ParameterAcceptor() override;
380
417 static void
418 initialize(const std::string &filename = "",
419 const std::string &output_filename = "",
421 output_style_for_output_filename = ParameterHandler::Short,
423 const ParameterHandler::OutputStyle output_style_for_filename =
425
435 static void
436 initialize(std::istream &input_stream,
438
439
443 static void
444 clear();
445
451 virtual void
453
460 boost::signals2::signal<void()> declare_parameters_call_back;
461
467 virtual void
469
479 boost::signals2::signal<void()> parse_parameters_call_back;
480
486 static void
488
495 static void
497
503 std::string
504 get_section_name() const;
505
510 std::vector<std::string>
511 get_section_path() const;
512
522 template <typename ParameterType>
523 void
524 add_parameter(const std::string &entry,
525 ParameterType &parameter,
526 const std::string &documentation = "",
527 ParameterHandler &prm_ = prm,
528 const Patterns::PatternBase &pattern =
530
535
587 void
588 enter_subsection(const std::string &subsection);
589
594 void
596
600 void
602
607 void
609
610private:
614 static unsigned int
616
620 static std::mutex class_list_mutex;
621
626 static std::set<ParameterAcceptor *, internal::ParameterAcceptorCompare>
628
630 const unsigned int acceptor_id;
631
635 static const char sep = '/';
636
637protected:
639 const std::string section_name;
640
642 std::vector<std::string> subsections;
643};
644
645
646
696template <class SourceClass>
698{
699public:
705 template <typename... Args>
706 ParameterAcceptorProxy(const std::string &section_name, Args... args);
707
712 virtual void
714
719 virtual void
721};
722
723
724
725// Inline and template functions
726template <typename ParameterType>
727void
728ParameterAcceptor::add_parameter(const std::string &entry,
729 ParameterType &parameter,
730 const std::string &documentation,
731 ParameterHandler &prm,
732 const Patterns::PatternBase &pattern)
733{
735 prm.add_parameter(entry, parameter, documentation, pattern);
737}
738
739
740
741template <class SourceClass>
742template <typename... Args>
744 const std::string &section_name,
745 Args... args)
746 : SourceClass(args...)
747 , ParameterAcceptor(section_name)
748{}
749
750
751
752template <class SourceClass>
753void
755{
756 SourceClass::declare_parameters(prm);
757}
758
759
760
761template <class SourceClass>
762void
764{
765 SourceClass::parse_parameters(prm);
766}
767
769
770#endif
virtual void declare_parameters(ParameterHandler &prm) override
virtual void parse_parameters(ParameterHandler &prm) override
ParameterAcceptorProxy(const std::string &section_name, Args... args)
virtual ~ParameterAcceptor() override
std::string get_section_name() const
boost::signals2::signal< void()> declare_parameters_call_back
static const char sep
static void declare_all_parameters(ParameterHandler &prm=ParameterAcceptor::prm)
unsigned int get_acceptor_id() const
const unsigned int acceptor_id
const std::string section_name
std::vector< std::string > subsections
static void initialize(const std::string &filename="", const std::string &output_filename="", const ParameterHandler::OutputStyle output_style_for_output_filename=ParameterHandler::Short, ParameterHandler &prm=ParameterAcceptor::prm, const ParameterHandler::OutputStyle output_style_for_filename=ParameterHandler::DefaultStyle)
static ParameterHandler prm
void leave_my_subsection(ParameterHandler &prm)
void enter_subsection(const std::string &subsection)
virtual void parse_parameters(ParameterHandler &prm)
static unsigned int get_next_free_id()
static void parse_all_parameters(ParameterHandler &prm=ParameterAcceptor::prm)
boost::signals2::signal< void()> parse_parameters_call_back
void enter_my_subsection(ParameterHandler &prm)
static std::mutex class_list_mutex
static std::set< ParameterAcceptor *, internal::ParameterAcceptorCompare > class_list
void add_parameter(const std::string &entry, ParameterType &parameter, const std::string &documentation="", ParameterHandler &prm_=prm, const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern())
virtual void declare_parameters(ParameterHandler &prm)
std::vector< std::string > get_section_path() const
void add_parameter(const std::string &entry, ParameterType &parameter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern(), const bool has_to_be_set=false)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503