Cantera  3.1.0a1
Delegator.h
Go to the documentation of this file.
1 //! @file Delegator.h
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at https://cantera.org/license.txt for license and copyright information.
5 
6 #ifndef CT_DELEGATOR_H
7 #define CT_DELEGATOR_H
8 
9 #include "cantera/base/global.h"
10 #include "cantera/base/Units.h"
13 #include <array>
14 #include <list>
15 
16 namespace Cantera
17 {
18 
19 //! Delegate member functions of a C++ class to externally-specified functions
20 /*!
21  * This base class provides functions for setting delegates for the member
22  * functions of a C++ class at runtime. The purpose of this capability is to
23  * allow the class to be extended using functions defined in any programming
24  * language that provides a C API for calling functions in that language.
25  *
26  * Delegates are specified as `std::function` objects that are responsible for
27  * encapsulating the data specific to the target language and calling the
28  * appropriate function in the target language. The `std::function` has a
29  * modified function signature compared to the method that it is replacing or
30  * augmenting:
31  * - Methods with no return value and scalar arguments are treated the same
32  * - Methods with a return value have that value as the first reference argument
33  * of their delegate function, and return an `int`. The delegate should return
34  * zero if it does not set the arguments value, and a non-zero value if it
35  * does.
36  * - Methods with pointers to arrays as arguments have an additional argument
37  * introduced to indicate the length of each array argument. This argument
38  * occurs either first, or after the return value reference, and is a
39  * `std::array<size_t, N>` where N is the number of array arguments.
40  *
41  * Delegated methods can be specified to either "replace" the original class's
42  * method, or to run "before" or "after" the original method, using the `when`
43  * parameter of the `setDelegate` method. There are two special cases for delegates of
44  * methods with return values:
45  * - If the "before" delegate specifies a value for the return parameter (and then
46  * returns with a non-zero status value), this value will be returned and the original
47  * method will not be called. Otherwise, the original method will be called and its
48  * value will be returned.
49  * - If an "after" delegate specifies a return value (and returns with a non-zero
50  * status value), this value will be added to the value returned by the original
51  * method, and this combined result will be then be returned. The meaning of "added"
52  * is determined by the `+` operator for the return type, for example addition for
53  * numeric types or concatenation for strings.
54  *
55  * ## Implementation for each delegated function type
56  *
57  * Several functions and member variables are defined in this base class for each
58  * distinct function signature that can be delegated by a derived class such as
59  * ReactorDelegator. These are:
60  * - The `install` function stores the address of a function that will be called by
61  * a derived delegator class in the corresponding `m_funcs_...` map, and sets the
62  * default implementation of this method (which should be to call the base class
63  * implementation). For delegates with a return type, a copy of this default
64  * implementation is also stored in the corresponding `m_base_...` map
65  * - The `setDelegate` function wraps the user-provided delegate in a function that
66  * handles whether the delegate is to be called before, after, or instead of the base
67  * class's implementation. This function is then stored at the address specified in
68  * the corresponding `m_funcs_...` map.
69  * - `m_funcs_...` is a mapping between member function names and the addresses
70  * of the functions that will be called to implement these functions in the derived
71  * delegator class.
72  * - `m_base_...` is a mapping between member function names and the default
73  * implementations of these member functions, for delegates with return values
74  *
75  * Additional implementation for each function type is specific to the programming
76  * language that the delegate is written in. For the Python delegates, see additional
77  * documentation in `delegator.pyx`.
78  *
79  * ## Implementation for specific delegated functions
80  *
81  * Beyond the implementation of particular function signatures, there are no elements
82  * of the Delegator class that are specific to individual delegated functions, which
83  * are handled by derived classes such as ReactorDelegator, which will also inherit from
84  * another base class such as Reactor.
85  *
86  * Delegation of a member function (for example, `Reactor::eval`) is handled by several
87  * elements:
88  * - A `std::function` member variable to hold a delegate function, or its default
89  * implementation. This function type includes the additional `std::array` argument
90  * of array sizes for functions with array arguments.
91  * - An override of the member function whose implementation calls the stored delegate.
92  * For delegates that need an array of array sizes, this function first calculates the
93  * necessary values and passes them as an additional argument to the delegate.
94  * - A call to `install` from the constructor of the derived delegator class, which
95  * takes the member function name, a reference to the `std::function` member variable
96  * described above, and a lambda function that implements the default behavior, that
97  * is, calling the equivalent base class method.
98  *
99  * Additional implementation for each function is specific to the programming language
100  * that the delegate is written in. For Python delegates, see additional documentation
101  * in `delegator.pyx`.
102  */
104 {
105 public:
106  //! Get the name of the user-defined class in the extension language
107  string delegatorName() const {
108  return m_delegatorName;
109  }
110 
111  //! Set the name of the user-defined class in the extension language
112  void setDelegatorName(const string& delegatorName) {
114  }
115 
116  //! Set delegates for member functions with the signature `void()`.
117  void setDelegate(const string& name, const function<void()>& func,
118  const string& when)
119  {
120  if (!m_funcs_v.count(name)) {
121  throw NotImplementedError("Delegator::setDelegate",
122  "for function named '{}' with signature 'void()'.", name);
123  }
124  *m_funcs_v[name] = makeDelegate(func, when, *m_funcs_v[name]);
125  }
126 
127  //! set delegates for member functions with the signature `void(bool)`
128  void setDelegate(const string& name, const function<void(bool)>& func,
129  const string& when)
130  {
131  if (!m_funcs_v_b.count(name)) {
132  throw NotImplementedError("Delegator::setDelegate",
133  "for function named '{}' with signature 'void(bool)'.", name);
134  }
135  *m_funcs_v_b[name] = makeDelegate(func, when, *m_funcs_v_b[name]);
136  }
137 
138  //! set delegates for member functions with the signature `void(double)`
139  void setDelegate(const string& name, const function<void(double)>& func,
140  const string& when)
141  {
142  if (!m_funcs_v_d.count(name)) {
143  throw NotImplementedError("Delegator::setDelegate",
144  "for function named '{}' with signature 'void(double)'.", name);
145  }
146  *m_funcs_v_d[name] = makeDelegate(func, when, *m_funcs_v_d[name]);
147  }
148 
149  //! set delegates for member functions with the signature `void(AnyMap&)`
150  void setDelegate(const string& name, const function<void(AnyMap&)>& func,
151  const string& when)
152  {
153  if (!m_funcs_v_AMr.count(name)) {
154  throw NotImplementedError("Delegator::setDelegate",
155  "for function named '{}' with signature 'void(AnyMap&)'.", name);
156  }
157  *m_funcs_v_AMr[name] = makeDelegate(func, when, *m_funcs_v_AMr[name]);
158  }
159 
160  //! set delegates for member functions with the signature
161  //! `void(AnyMap&, UnitStack&)`
162  void setDelegate(const string& name,
163  const function<void(const AnyMap&, const UnitStack&)>& func,
164  const string& when)
165  {
166  if (!m_funcs_v_cAMr_cUSr.count(name)) {
167  throw NotImplementedError("Delegator::setDelegate",
168  "for function named '{}' with signature "
169  "'void(const AnyMap&, const UnitStack&)'.",
170  name);
171  }
172  *m_funcs_v_cAMr_cUSr[name] = makeDelegate(func, when, *m_funcs_v_cAMr_cUSr[name]);
173  }
174 
175  //! set delegates for member functions with the signature
176  //! `void(const string&, void*)`
177  void setDelegate(const string& name,
178  const function<void(const string&, void*)>& func,
179  const string& when)
180  {
181  if (!m_funcs_v_csr_vp.count(name)) {
182  throw NotImplementedError("Delegator::setDelegate",
183  "for function named '{}' with signature 'void(const string&, void*)'.");
184  }
185  *m_funcs_v_csr_vp[name] = makeDelegate(func, when, *m_funcs_v_csr_vp[name]);
186  }
187 
188  //! Set delegates for member functions with the signature `void(double*)`
189  void setDelegate(const string& name,
190  const function<void(std::array<size_t, 1>, double*)>& func,
191  const string& when)
192  {
193  if (!m_funcs_v_dp.count(name)) {
194  throw NotImplementedError("Delegator::setDelegate",
195  "for function named '{}' with signature 'void(double*)'.", name);
196  }
197  *m_funcs_v_dp[name] = makeDelegate(func, when, *m_funcs_v_dp[name]);
198  }
199 
200  //! Set delegates for member functions with the signature `void(double, double*)`
202  const string& name,
203  const function<void(std::array<size_t, 1>, double, double*)>& func,
204  const string& when)
205  {
206  if (!m_funcs_v_d_dp.count(name)) {
207  throw NotImplementedError("Delegator::setDelegate",
208  "for function named '{}' with signature 'void(double, double*)'.",
209  name);
210  }
211  *m_funcs_v_d_dp[name] = makeDelegate(func, when, *m_funcs_v_d_dp[name]);
212  }
213 
214  //! Set delegates for member functions with the signature
215  //! `void(double, double*, double*)`
217  const string& name,
218  const function<void(std::array <size_t, 2>, double, double*, double*)>& func,
219  const string& when)
220  {
221  if (!m_funcs_v_d_dp_dp.count(name)) {
222  throw NotImplementedError("Delegator::setDelegate",
223  "for function named '{}' with signature "
224  "'void(double, double*, double*)'.", name);
225  }
226  *m_funcs_v_d_dp_dp[name] = makeDelegate(func, when, *m_funcs_v_d_dp_dp[name]);
227  }
228 
229  //! Set delegates for member functions with the signature
230  //! `void(double*, double*, double*)`
232  const string& name,
233  const function<void(std::array<size_t, 3>, double*, double*, double*)>& func,
234  const string& when)
235  {
236  if (!m_funcs_v_dp_dp_dp.count(name)) {
237  throw NotImplementedError("Delegator::setDelegate",
238  "for function named '{}' with signature "
239  "'void(double*, double*, double*)'.", name);
240  }
241  *m_funcs_v_dp_dp_dp[name] = makeDelegate(func, when, *m_funcs_v_dp_dp_dp[name]);
242  }
243 
244  //! set delegates for member functions with the signature `double(void*)`
245  void setDelegate(const string& name,
246  const function<int(double&, void*)>& func,
247  const string& when)
248  {
249  if (!m_funcs_d_vp.count(name)) {
250  throw NotImplementedError("Delegator::setDelegate",
251  "for function named '{}' with signature 'double(void*)'.", name);
252  }
253  *m_funcs_d_vp[name] = makeDelegate(name, func, when, m_base_d_vp[name]);
254  }
255 
256  //! Set delegates for member functions with the signature `string(size_t)`
257  void setDelegate(const string& name,
258  const function<int(string&, size_t)>& func,
259  const string& when)
260  {
261  if (!m_funcs_s_sz.count(name)) {
262  throw NotImplementedError("Delegator::setDelegate",
263  "for function named '{}' with signature "
264  "'string(size_t)'.", name);
265  }
266  *m_funcs_s_sz[name] = makeDelegate(name, func, when, m_base_s_sz[name]);
267  }
268 
269  //! Set delegates for member functions with the signature `size_t(string)`
270  void setDelegate(const string& name,
271  const function<int(size_t&, const string&)>& func,
272  const string& when)
273  {
274  if (!m_funcs_sz_csr.count(name)) {
275  throw NotImplementedError("Delegator::setDelegate",
276  "for function '{}' with signature "
277  "'size_t(const string&)'.", name);
278  }
279  *m_funcs_sz_csr[name] = makeDelegate(name, func, when, m_base_sz_csr[name]);
280  }
281 
282  //! Store a handle to a wrapper for the delegate from an external language interface
283  void holdExternalHandle(const string& name,
284  const shared_ptr<ExternalHandle>& handle) {
285  m_handles[name] = handle;
286  }
287 
288  //! Get the handle for a wrapper for the delegate from the external language
289  //! interface specified by *name*.
290  //! Returns a null pointer if the requested handle does not exist.
291  shared_ptr<ExternalHandle> getExternalHandle(const string& name) const {
292  if (m_handles.count(name)) {
293  return m_handles.at(name);
294  } else {
295  return shared_ptr<ExternalHandle>();
296  }
297  }
298 
299 protected:
300  //! Install a function with the signature `void()` as being delegatable
301  void install(const string& name, function<void()>& target,
302  const function<void()>& func)
303  {
304  target = func;
305  m_funcs_v[name] = &target;
306  }
307 
308  //! Install a function with the signature `void(bool)` as being delegatable
309  void install(const string& name, function<void(bool)>& target,
310  const function<void(bool)>& func)
311  {
312  target = func;
313  m_funcs_v_b[name] = &target;
314  }
315 
316  //! Install a function with the signature `void(double)` as being delegatable
317  void install(const string& name, function<void(double)>& target,
318  const function<void(double)>& func)
319  {
320  target = func;
321  m_funcs_v_d[name] = &target;
322  }
323 
324  //! Install a function with the signature `void(AnyMap&)` as being delegatable
325  void install(const string& name, function<void(AnyMap&)>& target,
326  const function<void(AnyMap&)>& func)
327  {
328  target = func;
329  m_funcs_v_AMr[name] = &target;
330  }
331 
332  //! Install a function with the signature `void(const AnyMap&, const UnitStack&)`
333  //! as being delegatable
334  void install(const string& name,
335  function<void(const AnyMap&, const UnitStack&)>& target,
336  const function<void(const AnyMap&, const UnitStack&)>& func)
337  {
338  target = func;
339  m_funcs_v_cAMr_cUSr[name] = &target;
340  }
341 
342  //! Install a function with the signature `void(const string&, void*) as being
343  //! delegatable
344  void install(const string& name, function<void(const string&, void*)>& target,
345  const function<void(const string&, void*)>& func)
346  {
347  target = func;
348  m_funcs_v_csr_vp[name] = &target;
349  }
350 
351  //! Install a function with the signature `void(double*)` as being delegatable
352  void install(const string& name,
353  function<void(std::array<size_t, 1>, double*)>& target,
354  const function<void(std::array<size_t, 1>, double*)>& func)
355  {
356  target = func;
357  m_funcs_v_dp[name] = &target;
358  }
359 
360  //! Install a function with the signature `void(double, double*)` as being delegatable
361  void install(const string& name,
362  function<void(std::array<size_t, 1>, double, double*)>& target,
363  const function<void(std::array<size_t, 1>, double, double*)>& func)
364  {
365  target = func;
366  m_funcs_v_d_dp[name] = &target;
367  }
368 
369  //! Install a function with the signature `void(double, double*, double*)` as being
370  //! delegatable
371  void install(const string& name,
372  function<void(std::array<size_t, 2>, double, double*, double*)>& target,
373  const function<void(std::array<size_t, 2>, double, double*, double*)>& func)
374  {
375  target = func;
376  m_funcs_v_d_dp_dp[name] = &target;
377  }
378 
379  //! Install a function with the signature
380  //! `void(double*, double*, double*)` as being delegatable
381  void install(const string& name,
382  function<void(std::array<size_t, 3>, double*, double*, double*)>& target,
383  const function<void(std::array<size_t, 3>, double*, double*, double*)>& base)
384  {
385  target = base;
386  m_funcs_v_dp_dp_dp[name] = &target;
387  }
388 
389  //! Install a function with the signature `double(void*)` as being delegatable
390  void install(const string& name, function<double(void*)>& target,
391  const function<double(void*)>& func)
392  {
393  target = func;
394  m_funcs_d_vp[name] = &target;
395  }
396 
397  //! Install a function with the signature `string(size_t)` as being delegatable
398  void install(const string& name,
399  function<string(size_t)>& target,
400  const function<string(size_t)>& base)
401  {
402  target = base;
403  m_funcs_s_sz[name] = &target;
404  m_base_s_sz[name] = base;
405  }
406 
407  //! Install a function with the signature `size_t(string)` as being delegatable
408  void install(const string& name,
409  function<size_t(const string&)>& target,
410  const function<size_t(const string&)>& base)
411  {
412  target = base;
413  m_funcs_sz_csr[name] = &target;
414  m_base_sz_csr[name] = base;
415  }
416 
417  //! Create a delegate for a function with no return value
418  template <typename BaseFunc, class ... Args>
419  function<void(Args ...)> makeDelegate(
420  const function<void(Args ...)>& func,
421  const string& when,
422  BaseFunc base)
423  {
424  if (when == "before") {
425  return [base, func](Args ... args) {
426  func(args ...);
427  base(args ...);
428  };
429  } else if (when == "after") {
430  return [base, func](Args ... args) {
431  base(args ...);
432  func(args ...);
433  };
434  } else if (when == "replace") {
435  return [func](Args ... args) {
436  func(args ...);
437  };
438  } else {
439  throw CanteraError("Delegator::makeDelegate",
440  "'when' must be one of 'before', 'after', or 'replace';"
441  " not '{}", when);
442  }
443  }
444 
445  //! Create a delegate for a function with a return value
446  template <typename ReturnType, class ... Args>
447  function<ReturnType(Args ...)> makeDelegate(
448  const string& name,
449  const function<int(ReturnType&, Args ...)>& func,
450  const string& when,
451  const function<ReturnType(Args ...)>& base)
452  {
453  if (when == "before") {
454  return [base, func](Args ... args) {
455  // Call the provided delegate first. If it sets the return
456  // value, return that, otherwise return the value from the
457  // original method
458  ReturnType ret;
459  int done = func(ret, args ...);
460  if (done) {
461  return ret;
462  } else {
463  return base(args ...);
464  }
465  };
466  } else if (when == "after") {
467  return [base, func](Args ... args) {
468  // Add the value returned by the original method and the
469  // provided delegate
470  ReturnType ret1 = base(args ...);
471  ReturnType ret2;
472  int done = func(ret2, args ...);
473  if (done) {
474  return ret1 + ret2;
475  } else {
476  return ret1;
477  }
478  };
479  } else if (when == "replace") {
480  return [base, name, func, this](Args ... args) {
481  ReturnType ret;
482  int has_ret = func(ret, args ...);
483  if (!has_ret) {
484  throw CanteraError("Lambda generated by Delegator::makeDelegate",
485  "Method '{}' of class '{}' did not return a value of type '{}'.",
486  name, delegatorName(), demangle(typeid(ret)));
487  }
488  return ret;
489  };
490  } else {
491  throw CanteraError("Delegator::makeDelegate",
492  "For function named '{}':\n"
493  "'when' must be one of 'before', 'after', or 'replace';"
494  " not '{}'", name, when);
495  }
496  }
497 
498  //! @name Containers for delegates and base class implementations.
499  //!
500  //! Maps named `m_funcs_*` hold the current delegate. For functions with a return
501  //! value, `m_base_*` holds a pointer to the base class's implementation of the
502  //! function.
503  //!
504  //! These containers use a naming scheme based on the signature of the corresponding
505  //! member functions. Following the prefix `_m_funcs_` is a notation of the return
506  //! type, followed by an underscore, then the notations for each argument, separated
507  //! by underscores. The following shorthand is used for different return / argument
508  //! types:
509  //!
510  //! - `v` for `void`
511  //! - `b` for `bool`
512  //! - `d` for `double`
513  //! - `s` for `string`
514  //! - `sz` for `size_t`
515  //! - `AM` for `AnyMap`
516  //! - `US` for `UnitStack`
517  //! - prefix `c` for `const` arguments
518  //! - suffix `r` for reference arguments
519  //! - suffix `p` for pointer arguments
520  //! @{
521 
522  // Delegates with no return value
523  map<string, function<void()>*> m_funcs_v;
524  map<string, function<void(bool)>*> m_funcs_v_b;
525  map<string, function<void(double)>*> m_funcs_v_d;
526  map<string, function<void(AnyMap&)>*> m_funcs_v_AMr;
527  map<string, function<void(const AnyMap&, const UnitStack&)>*> m_funcs_v_cAMr_cUSr;
528  map<string, function<void(const string&, void*)>*> m_funcs_v_csr_vp;
529  map<string, function<void(std::array<size_t, 1>, double*)>*> m_funcs_v_dp;
530  map<string, function<void(std::array<size_t, 1>, double, double*)>*> m_funcs_v_d_dp;
531  map<string,
532  function<void(std::array<size_t, 2>, double, double*, double*)>*> m_funcs_v_d_dp_dp;
533  map<string,
534  function<void(std::array<size_t, 3>, double*, double*, double*)>*> m_funcs_v_dp_dp_dp;
535 
536  // Delegates with a return value
537  map<string, function<double(void*)>> m_base_d_vp;
538  map<string, function<double(void*)>*> m_funcs_d_vp;
539 
540  map<string, function<string(size_t)>> m_base_s_sz;
541  map<string, function<string(size_t)>*> m_funcs_s_sz;
542 
543  map<string, function<size_t(const string&)>> m_base_sz_csr;
544  map<string, function<size_t(const string&)>*> m_funcs_sz_csr;
545  //! @}
546 
547  //! Handles to wrappers for the delegated object in external language interfaces.
548  //! Used to provide access to these wrappers as well as managing cleanup functions
549  //! called from the destructor of the derived ExternalHandle class.
550  map<string, shared_ptr<ExternalHandle>> m_handles;
551 
552  //! Name of the class in the extension language
554 };
555 
556 }
557 
558 #endif
Header for unit conversion utilities, which are used to translate user input from input files (See In...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:427
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:66
Delegate member functions of a C++ class to externally-specified functions.
Definition: Delegator.h:104
void install(const string &name, function< void(double)> &target, const function< void(double)> &func)
Install a function with the signature void(double) as being delegatable.
Definition: Delegator.h:317
void setDelegate(const string &name, const function< void(const AnyMap &, const UnitStack &)> &func, const string &when)
set delegates for member functions with the signature void(AnyMap&, UnitStack&)
Definition: Delegator.h:162
void setDelegate(const string &name, const function< int(string &, size_t)> &func, const string &when)
Set delegates for member functions with the signature string(size_t)
Definition: Delegator.h:257
shared_ptr< ExternalHandle > getExternalHandle(const string &name) const
Get the handle for a wrapper for the delegate from the external language interface specified by name.
Definition: Delegator.h:291
void setDelegate(const string &name, const function< void(bool)> &func, const string &when)
set delegates for member functions with the signature void(bool)
Definition: Delegator.h:128
void install(const string &name, function< void(bool)> &target, const function< void(bool)> &func)
Install a function with the signature void(bool) as being delegatable.
Definition: Delegator.h:309
void install(const string &name, function< void(std::array< size_t, 3 >, double *, double *, double *)> &target, const function< void(std::array< size_t, 3 >, double *, double *, double *)> &base)
Install a function with the signature void(double*, double*, double*) as being delegatable.
Definition: Delegator.h:381
void holdExternalHandle(const string &name, const shared_ptr< ExternalHandle > &handle)
Store a handle to a wrapper for the delegate from an external language interface.
Definition: Delegator.h:283
string delegatorName() const
Get the name of the user-defined class in the extension language.
Definition: Delegator.h:107
void install(const string &name, function< void(AnyMap &)> &target, const function< void(AnyMap &)> &func)
Install a function with the signature void(AnyMap&) as being delegatable.
Definition: Delegator.h:325
void setDelegate(const string &name, const function< void(double)> &func, const string &when)
set delegates for member functions with the signature void(double)
Definition: Delegator.h:139
void setDelegate(const string &name, const function< void(std::array< size_t, 1 >, double, double *)> &func, const string &when)
Set delegates for member functions with the signature void(double, double*)
Definition: Delegator.h:201
void setDelegate(const string &name, const function< void(const string &, void *)> &func, const string &when)
set delegates for member functions with the signature void(const string&, void*)
Definition: Delegator.h:177
void install(const string &name, function< size_t(const string &)> &target, const function< size_t(const string &)> &base)
Install a function with the signature size_t(string) as being delegatable.
Definition: Delegator.h:408
void install(const string &name, function< void(const AnyMap &, const UnitStack &)> &target, const function< void(const AnyMap &, const UnitStack &)> &func)
Install a function with the signature void(const AnyMap&, const UnitStack&) as being delegatable.
Definition: Delegator.h:334
void install(const string &name, function< double(void *)> &target, const function< double(void *)> &func)
Install a function with the signature double(void*) as being delegatable.
Definition: Delegator.h:390
void setDelegate(const string &name, const function< void(std::array< size_t, 2 >, double, double *, double *)> &func, const string &when)
Set delegates for member functions with the signature void(double, double*, double*)
Definition: Delegator.h:216
map< string, shared_ptr< ExternalHandle > > m_handles
Handles to wrappers for the delegated object in external language interfaces.
Definition: Delegator.h:550
void setDelegate(const string &name, const function< void(AnyMap &)> &func, const string &when)
set delegates for member functions with the signature void(AnyMap&)
Definition: Delegator.h:150
void install(const string &name, function< void()> &target, const function< void()> &func)
Install a function with the signature void() as being delegatable.
Definition: Delegator.h:301
void install(const string &name, function< void(std::array< size_t, 1 >, double *)> &target, const function< void(std::array< size_t, 1 >, double *)> &func)
Install a function with the signature void(double*) as being delegatable.
Definition: Delegator.h:352
void setDelegate(const string &name, const function< void(std::array< size_t, 1 >, double *)> &func, const string &when)
Set delegates for member functions with the signature void(double*)
Definition: Delegator.h:189
void setDelegate(const string &name, const function< int(size_t &, const string &)> &func, const string &when)
Set delegates for member functions with the signature size_t(string)
Definition: Delegator.h:270
void setDelegate(const string &name, const function< int(double &, void *)> &func, const string &when)
set delegates for member functions with the signature double(void*)
Definition: Delegator.h:245
void install(const string &name, function< void(std::array< size_t, 1 >, double, double *)> &target, const function< void(std::array< size_t, 1 >, double, double *)> &func)
Install a function with the signature void(double, double*) as being delegatable.
Definition: Delegator.h:361
void setDelegate(const string &name, const function< void()> &func, const string &when)
Set delegates for member functions with the signature void().
Definition: Delegator.h:117
void install(const string &name, function< string(size_t)> &target, const function< string(size_t)> &base)
Install a function with the signature string(size_t) as being delegatable.
Definition: Delegator.h:398
void install(const string &name, function< void(std::array< size_t, 2 >, double, double *, double *)> &target, const function< void(std::array< size_t, 2 >, double, double *, double *)> &func)
Install a function with the signature void(double, double*, double*) as being delegatable.
Definition: Delegator.h:371
string m_delegatorName
Name of the class in the extension language.
Definition: Delegator.h:553
void install(const string &name, function< void(const string &, void *)> &target, const function< void(const string &, void *)> &func)
Install a function with the signature `void(const string&, void*) as being delegatable.
Definition: Delegator.h:344
function< void(Args ...)> makeDelegate(const function< void(Args ...)> &func, const string &when, BaseFunc base)
Create a delegate for a function with no return value.
Definition: Delegator.h:419
void setDelegatorName(const string &delegatorName)
Set the name of the user-defined class in the extension language.
Definition: Delegator.h:112
function< ReturnType(Args ...)> makeDelegate(const string &name, const function< int(ReturnType &, Args ...)> &func, const string &when, const function< ReturnType(Args ...)> &base)
Create a delegate for a function with a return value.
Definition: Delegator.h:447
void setDelegate(const string &name, const function< void(std::array< size_t, 3 >, double *, double *, double *)> &func, const string &when)
Set delegates for member functions with the signature void(double*, double*, double*)
Definition: Delegator.h:231
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:195
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
string demangle(const std::type_info &type)
Convert a type name to a human readable string, using boost::core::demangle if available.
Definition: global.cpp:213
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:564
Unit aggregation utility.
Definition: Units.h:105