deal.II version GIT relicensing-2206-gaa53ff9447 2024-12-02 09:10:00+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 - 2024 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
23
24#include <boost/signals2/signal.hpp>
25
26#include <mutex>
27#include <typeinfo>
28
30
32
33namespace internal
34{
39 struct ParameterAcceptorCompare;
40} // namespace internal
41
359{
360public:
367 ParameterAcceptor(const std::string &section_name = "");
368
372 unsigned int
373 get_acceptor_id() const;
374
378 virtual ~ParameterAcceptor() override;
379
416 static void
417 initialize(const std::string &filename = "",
418 const std::string &output_filename = "",
420 output_style_for_output_filename = ParameterHandler::Short,
422 const ParameterHandler::OutputStyle output_style_for_filename =
424
434 static void
435 initialize(std::istream &input_stream,
437
438
442 static void
443 clear();
444
450 virtual void
452
459 boost::signals2::signal<void()> declare_parameters_call_back;
460
466 virtual void
468
478 boost::signals2::signal<void()> parse_parameters_call_back;
479
485 static void
487
494 static void
496
502 std::string
503 get_section_name() const;
504
509 std::vector<std::string>
510 get_section_path() const;
511
521 template <typename ParameterType>
522 void
523 add_parameter(const std::string &entry,
524 ParameterType &parameter,
525 const std::string &documentation = "",
526 ParameterHandler &prm_ = prm,
527 const Patterns::PatternBase &pattern =
529
534
586 void
587 enter_subsection(const std::string &subsection);
588
593 void
595
599 void
601
606 void
608
609private:
613 static unsigned int
615
619 static std::mutex class_list_mutex;
620
625 static std::set<ParameterAcceptor *, internal::ParameterAcceptorCompare>
627
629 const unsigned int acceptor_id;
630
634 static const char sep = '/';
635
636protected:
638 const std::string section_name;
639
641 std::vector<std::string> subsections;
642};
643
644
645
695template <class SourceClass>
697{
698public:
704 template <typename... Args>
705 ParameterAcceptorProxy(const std::string &section_name, Args... args);
706
711 virtual void
713
718 virtual void
720};
721
722
723
724// Inline and template functions
725template <typename ParameterType>
726void
727ParameterAcceptor::add_parameter(const std::string &entry,
728 ParameterType &parameter,
729 const std::string &documentation,
730 ParameterHandler &prm,
731 const Patterns::PatternBase &pattern)
732{
734 prm.add_parameter(entry, parameter, documentation, pattern);
736}
737
738
739
740template <class SourceClass>
741template <typename... Args>
743 const std::string &section_name,
744 Args... args)
745 : SourceClass(args...)
746 , ParameterAcceptor(section_name)
747{}
748
749
750
751template <class SourceClass>
752void
754{
755 SourceClass::declare_parameters(prm);
756}
757
758
759
760template <class SourceClass>
761void
763{
764 SourceClass::parse_parameters(prm);
765}
766
768
769#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:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499