Reference documentation for deal.II version 9.2.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\}}\)
parameter_acceptor.h
Go to the documentation of this file.
1 //-----------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2020 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 
22 #include <deal.II/base/logstream.h>
25 
26 #include <boost/signals2/signal.hpp>
27 
28 #include <typeinfo>
29 
31 
351 {
352 public:
359  ParameterAcceptor(const std::string &section_name = "");
360 
364  virtual ~ParameterAcceptor() override;
365 
402  static void
403  initialize(const std::string &filename = "",
404  const std::string &output_filename = "",
406  output_style_for_output_filename = ParameterHandler::Short,
408  const ParameterHandler::OutputStyle output_style_for_filename =
410 
420  static void
421  initialize(std::istream & input_stream,
423 
424 
428  static void
429  clear();
430 
436  virtual void
438 
445  boost::signals2::signal<void()> declare_parameters_call_back;
446 
452  virtual void
454 
464  boost::signals2::signal<void()> parse_parameters_call_back;
465 
471  static void
473 
480  static void
482 
488  std::string
489  get_section_name() const;
490 
495  std::vector<std::string>
496  get_section_path() const;
497 
507  template <class ParameterType>
508  void
509  add_parameter(const std::string & entry,
510  ParameterType & parameter,
511  const std::string & documentation = "",
512  ParameterHandler & prm_ = prm,
513  const Patterns::PatternBase &pattern =
515 
520 
524  void
526 
531  void
533 
534 private:
539  static std::vector<SmartPointer<ParameterAcceptor>> class_list;
540 
542  const unsigned int acceptor_id;
543 
547  static const char sep = '/';
548 
549 protected:
551  const std::string section_name;
552 };
553 
554 
555 
607 template <class SourceClass>
609 {
610 public:
616  template <typename... Args>
617  ParameterAcceptorProxy(const std::string &section_name, Args... args);
618 
623  virtual void
625 
630  virtual void
632 };
633 
634 
635 
636 // Inline and template functions
637 template <class ParameterType>
638 void
639 ParameterAcceptor::add_parameter(const std::string & entry,
640  ParameterType & parameter,
641  const std::string & documentation,
642  ParameterHandler & prm,
643  const Patterns::PatternBase &pattern)
644 {
646  prm.add_parameter(entry, parameter, documentation, pattern);
648 }
649 
650 
651 
652 template <class SourceClass>
653 template <typename... Args>
655  const std::string &section_name,
656  Args... args)
657  : SourceClass(args...)
658  , ParameterAcceptor(section_name)
659 {}
660 
661 
662 
663 template <class SourceClass>
664 void
666 {
667  SourceClass::declare_parameters(prm);
668 }
669 
670 
671 
672 template <class SourceClass>
673 void
675 {
676  SourceClass::parse_parameters(prm);
677 }
678 
680 
681 #endif
ParameterHandler::OutputStyle
OutputStyle
Definition: parameter_handler.h:863
ParameterAcceptor::parse_all_parameters
static void parse_all_parameters(ParameterHandler &prm=ParameterAcceptor::prm)
Definition: parameter_acceptor.cc:121
ParameterAcceptor::parse_parameters
virtual void parse_parameters(ParameterHandler &prm)
Definition: parameter_acceptor.cc:115
ParameterAcceptor::parse_parameters_call_back
boost::signals2::signal< void()> parse_parameters_call_back
Definition: parameter_acceptor.h:464
Patterns::PatternBase
Definition: patterns.h:80
ParameterAcceptor::enter_my_subsection
void enter_my_subsection(ParameterHandler &prm)
Definition: parameter_acceptor.cc:189
ParameterAcceptorProxy::parse_parameters
virtual void parse_parameters(ParameterHandler &prm) override
Definition: parameter_acceptor.h:674
ParameterAcceptor::class_list
static std::vector< SmartPointer< ParameterAcceptor > > class_list
Definition: parameter_acceptor.h:539
ParameterAcceptor::declare_all_parameters
static void declare_all_parameters(ParameterHandler &prm=ParameterAcceptor::prm)
Definition: parameter_acceptor.cc:134
Subscriptor
Definition: subscriptor.h:62
ParameterAcceptor::add_parameter
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())
Definition: parameter_acceptor.h:639
ParameterAcceptor::declare_parameters_call_back
boost::signals2::signal< void()> declare_parameters_call_back
Definition: parameter_acceptor.h:445
ParameterAcceptor::clear
static void clear()
Definition: parameter_acceptor.cc:100
Patterns::Tools::Convert
Definition: patterns.h:1305
SourceClass
ParameterAcceptor::ParameterAcceptor
ParameterAcceptor(const std::string &section_name="")
Definition: parameter_acceptor.cc:32
ParameterAcceptor::initialize
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)
Definition: parameter_acceptor.cc:56
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
ParameterAcceptor::~ParameterAcceptor
virtual ~ParameterAcceptor() override
Definition: parameter_acceptor.cc:42
ParameterAcceptor::get_section_name
std::string get_section_name() const
Definition: parameter_acceptor.cc:48
ParameterAcceptor::get_section_path
std::vector< std::string > get_section_path() const
Definition: parameter_acceptor.cc:148
parameter_handler.h
smartpointer.h
ParameterAcceptorProxy
Definition: parameter_acceptor.h:608
ParameterAcceptor::prm
static ParameterHandler prm
Definition: parameter_acceptor.h:519
exceptions.h
ParameterAcceptor::sep
static const char sep
Definition: parameter_acceptor.h:547
ParameterAcceptor::declare_parameters
virtual void declare_parameters(ParameterHandler &prm)
Definition: parameter_acceptor.cc:109
ParameterAcceptor::section_name
const std::string section_name
Definition: parameter_acceptor.h:551
ParameterHandler::Short
@ Short
Definition: parameter_handler.h:875
ParameterHandler::DefaultStyle
@ DefaultStyle
Definition: parameter_handler.h:869
ParameterHandler::add_parameter
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)
Definition: parameter_handler.h:2328
ParameterHandler
Definition: parameter_handler.h:845
config.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
logstream.h
ParameterAcceptor
Definition: parameter_acceptor.h:350
ParameterAcceptorProxy::ParameterAcceptorProxy
ParameterAcceptorProxy(const std::string &section_name, Args... args)
Definition: parameter_acceptor.h:654
ParameterAcceptor::leave_my_subsection
void leave_my_subsection(ParameterHandler &prm)
Definition: parameter_acceptor.cc:200
ParameterAcceptorProxy::declare_parameters
virtual void declare_parameters(ParameterHandler &prm) override
Definition: parameter_acceptor.h:665
ParameterAcceptor::acceptor_id
const unsigned int acceptor_id
Definition: parameter_acceptor.h:542