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