Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
parameter_acceptor.h
1 //-----------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2018 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 
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/logstream.h>
23 #include <deal.II/base/parameter_handler.h>
24 #include <deal.II/base/smartpointer.h>
25 
26 #include <boost/signals2/signal.hpp>
27 
28 #include <typeinfo>
29 
30 DEAL_II_NAMESPACE_OPEN
31 
351 {
352 public:
359  ParameterAcceptor(const std::string &section_name = "");
360 
364  virtual ~ParameterAcceptor() override;
365 
393  static void
394  initialize(const std::string & filename = "",
395  const std::string & output_filename = "",
396  const ParameterHandler::OutputStyle output_style_for_prm_format =
399 
409  static void
410  initialize(std::istream & input_stream,
412 
413 
417  static void
418  clear();
419 
425  virtual void
427 
434  boost::signals2::signal<void()> declare_parameters_call_back;
435 
441  virtual void
443 
453  boost::signals2::signal<void()> parse_parameters_call_back;
454 
460  static void
462 
469  static void
471 
477  std::string
478  get_section_name() const;
479 
484  std::vector<std::string>
485  get_section_path() const;
486 
496  template <class ParameterType>
497  void
498  add_parameter(const std::string & entry,
499  ParameterType & parameter,
500  const std::string & documentation = "",
501  ParameterHandler & prm_ = prm,
502  const Patterns::PatternBase &pattern =
504 
509 
513  void
515 
520  void
522 
523 private:
528  static std::vector<SmartPointer<ParameterAcceptor>> class_list;
529 
531  const unsigned int acceptor_id;
532 
536  static const char sep = '/';
537 
538 protected:
540  const std::string section_name;
541 };
542 
543 
544 
596 template <class SourceClass>
597 class ParameterAcceptorProxy : public SourceClass, public ParameterAcceptor
598 {
599 public:
605  template <typename... Args>
606  ParameterAcceptorProxy(const std::string section_name, Args... args);
607 
612  virtual void
614 
619  virtual void
621 };
622 
623 
624 
625 // Inline and template functions
626 template <class ParameterType>
627 void
628 ParameterAcceptor::add_parameter(const std::string & entry,
629  ParameterType & parameter,
630  const std::string & documentation,
631  ParameterHandler & prm,
632  const Patterns::PatternBase &pattern)
633 {
635  prm.add_parameter(entry, parameter, documentation, pattern);
637 }
638 
639 
640 
641 template <class SourceClass>
642 template <typename... Args>
644  const std::string section_name,
645  Args... args)
646  : SourceClass(args...)
647  , ParameterAcceptor(section_name)
648 {}
649 
650 
651 
652 template <class SourceClass>
653 void
655 {
656  SourceClass::declare_parameters(prm);
657 }
658 
659 
660 
661 template <class SourceClass>
662 void
664 {
665  SourceClass::parse_parameters(prm);
666 }
667 
668 DEAL_II_NAMESPACE_CLOSE
669 
670 #endif
const unsigned int acceptor_id
virtual void declare_parameters(ParameterHandler &prm) override
static void initialize(const std::string &filename="", const std::string &output_filename="", const ParameterHandler::OutputStyle output_style_for_prm_format=ParameterHandler::ShortText, ParameterHandler &prm=ParameterAcceptor::prm)
void enter_my_subsection(ParameterHandler &prm)
static void declare_all_parameters(ParameterHandler &prm=ParameterAcceptor::prm)
virtual void parse_parameters(ParameterHandler &prm)
virtual void parse_parameters(ParameterHandler &prm) override
ParameterAcceptorProxy(const std::string section_name, Args... args)
ParameterAcceptor(const std::string &section_name="")
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())
boost::signals2::signal< void()> declare_parameters_call_back
static std::vector< SmartPointer< ParameterAcceptor > > class_list
void add_parameter(const std::string &entry, ParameterType &parameter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern())
virtual ~ParameterAcceptor() override
std::string get_section_name() const
static const char sep
std::vector< std::string > get_section_path() const
virtual void declare_parameters(ParameterHandler &prm)
static ParameterHandler prm
static void parse_all_parameters(ParameterHandler &prm=ParameterAcceptor::prm)
const std::string section_name
void leave_my_subsection(ParameterHandler &prm)
boost::signals2::signal< void()> parse_parameters_call_back