Reference documentation for deal.II version 9.5.0
\(\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// Copyright (C) 2017 - 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14//-----------------------------------------------------------
15
16#ifndef dealii_base_parameter_acceptor_h
17#define dealii_base_parameter_acceptor_h
18
19#include <deal.II/base/config.h>
20
25
26#include <boost/signals2/signal.hpp>
27
28#include <mutex>
29#include <typeinfo>
30
32
34
35namespace internal
36{
41 struct ParameterAcceptorCompare;
42} // namespace internal
43
361{
362public:
369 ParameterAcceptor(const std::string &section_name = "");
370
374 unsigned int
375 get_acceptor_id() const;
376
380 virtual ~ParameterAcceptor() override;
381
418 static void
419 initialize(const std::string &filename = "",
420 const std::string &output_filename = "",
422 output_style_for_output_filename = ParameterHandler::Short,
424 const ParameterHandler::OutputStyle output_style_for_filename =
426
436 static void
437 initialize(std::istream & input_stream,
439
440
444 static void
445 clear();
446
452 virtual void
454
461 boost::signals2::signal<void()> declare_parameters_call_back;
462
468 virtual void
470
480 boost::signals2::signal<void()> parse_parameters_call_back;
481
487 static void
489
496 static void
498
504 std::string
505 get_section_name() const;
506
511 std::vector<std::string>
512 get_section_path() const;
513
523 template <class ParameterType>
524 void
525 add_parameter(const std::string & entry,
526 ParameterType & parameter,
527 const std::string & documentation = "",
528 ParameterHandler & prm_ = prm,
529 const Patterns::PatternBase &pattern =
531
536
588 void
589 enter_subsection(const std::string &subsection);
590
595 void
597
601 void
603
608 void
610
611private:
615 static unsigned int
617
621 static std::mutex class_list_mutex;
622
627 static std::set<ParameterAcceptor *, internal::ParameterAcceptorCompare>
629
631 const unsigned int acceptor_id;
632
636 static const char sep = '/';
637
638protected:
640 const std::string section_name;
641
643 std::vector<std::string> subsections;
644};
645
646
647
697template <class SourceClass>
699{
700public:
706 template <typename... Args>
707 ParameterAcceptorProxy(const std::string &section_name, Args... args);
708
713 virtual void
715
720 virtual void
722};
723
724
725
726// Inline and template functions
727template <class ParameterType>
728void
729ParameterAcceptor::add_parameter(const std::string & entry,
730 ParameterType & parameter,
731 const std::string & documentation,
732 ParameterHandler & prm,
733 const Patterns::PatternBase &pattern)
734{
736 prm.add_parameter(entry, parameter, documentation, pattern);
738}
739
740
741
742template <class SourceClass>
743template <typename... Args>
745 const std::string &section_name,
746 Args... args)
747 : SourceClass(args...)
748 , ParameterAcceptor(section_name)
749{}
750
751
752
753template <class SourceClass>
754void
756{
757 SourceClass::declare_parameters(prm);
758}
759
760
761
762template <class SourceClass>
763void
765{
766 SourceClass::parse_parameters(prm);
767}
768
770
771#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:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473