Bayeux  3.4.1
Core Foundation library for SuperNEMO
math.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2015 by François Mauger <mauger@lpccaen.in2p3.fr>
5 //
6 // This file is part of Bayeux.
7 //
8 // Bayeux is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // Bayeux is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Bayeux. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef MYGSL_MATH_H
22 #define MYGSL_MATH_H
23 
24 // Standard library:
25 #include <string>
26 #include <map>
27 #include <iostream>
28 
29 namespace mygsl {
30 
32  typedef double (*plain_function_type)(double);
33 
35  typedef double (*plain_function_with_parameters_type)(double, void*);
36 
42  };
43 
46  void reset();
47  std::string name; //< Registration name of the plain function
51  };
52 
54  typedef std::map<std::string, plain_function_entry> plain_function_dict_type;
55 
58 
61  const std::string & name_,
62  const plain_function_type & func_);
63 
66  const std::string & name_,
67  const plain_function_with_parameters_type & func_with_params_);
68 
70  void tree_dump(const plain_function_dict_type & dict_,
71  std::ostream & out_ = std::clog,
72  const std::string & title_ = "",
73  const std::string & indent_ = "");
74 
76 
78 
79  bool plain_function_is_known(const std::string & name_);
80 
81  bool is_plain_function_simple(const std::string & name_);
82 
83  bool is_plain_function_with_params(const std::string & name_);
84 
85  plain_function_type get_simple_function(const std::string & name_);
86 
87 } // end of namespace mygsl
88 
89 #define MYGSL_MATH_REGISTER_FUNCTION(FunctionName, FunctionAddress, FunctionType) \
90  { \
91  if (FunctionType == mygsl::PLAIN_FUNCTION_SIMPLE) { \
92  register_plain_function_simple(mygsl::grab_plain_function_dict(), FunctionName, FunctionAddress); \
93  } else if (FunctionType == mygsl::PLAIN_FUNCTION_WITH_PARAMS) { \
94  register_plain_function_with_params(mygsl::grab_plain_function_dict(), FunctionName, FunctionAddress); \
95  } \
96  } \
97 
98 
99 #endif // MYGSL_MATH_H
100 
101 /* Local Variables: */
102 /* mode: c++ */
103 /* coding: utf-8 */
104 /* End: */
plain_function_dict_type & grab_plain_function_dict()
void reset()
Definition: math.h:44
plain_function_entry()
void basic_plain_function_registration(plain_function_dict_type &dict_)
Basic registration of some plain functions in a dictionary.
bool plain_function_is_known(const std::string &name_)
plain_function_flag
brief Describe the signature of function
Definition: math.h:38
plain_function_type func_simple
Address of the simple plain function.
Definition: math.h:49
bool is_plain_function_simple(const std::string &name_)
plain_function_with_parameters_type func_with_params
Address of the plain function with parameters.
Definition: math.h:50
void register_plain_function_with_params(plain_function_dict_type &dict_, const std::string &name_, const plain_function_with_parameters_type &func_with_params_)
Registration of a plain function with parameters.
plain_function_flag type
Type of the plain function.
Definition: math.h:48
Simple plain function.
Definition: math.h:40
double(* plain_function_with_parameters_type)(double, void *)
Typedef for a function C-style function with anonymous parameters :
Definition: math.h:35
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
std::string name
Definition: math.h:47
Simple plain function.
Definition: math.h:41
plain_function_type get_simple_function(const std::string &name_)
Invalid plain function.
Definition: math.h:39
void register_plain_function_simple(plain_function_dict_type &dict_, const std::string &name_, const plain_function_type &func_)
Registration of a plain simple function.
bool is_plain_function_with_params(const std::string &name_)
const plain_function_dict_type & get_plain_function_dict()
double(* plain_function_type)(double)
Typedef for a simple function C-style function :
Definition: math.h:32
std::map< std::string, plain_function_entry > plain_function_dict_type
Type alias for a dictionary of registered plain functions.
Definition: math.h:54
void tree_dump(const plain_function_dict_type &dict_, std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="")
Smart print of a dictionary of registered plain functions.