Cantera  3.2.0a2
Loading...
Searching...
No Matches
ctfunc.cpp
Go to the documentation of this file.
1/**
2 * CTFUNC - Generated CLib %Cantera interface library.
3 *
4 * @file ctfunc.cpp
5 *
6 * Generated CLib API for Cantera's Func1 class.
7 *
8 * This file was generated by sourcegen. It will be re-generated by the
9 * %Cantera build process. Do not manually edit.
10 *
11 * @warning This module is an experimental part of the %Cantera API and
12 * may be changed without notice.
13 */
14
15// This file is part of Cantera. See License.txt in the top-level directory or
16// at https://cantera.org/license.txt for license and copyright information.
17
18#include "clib_utils.h"
19#include "cantera_clib/ctfunc.h"
20
23
24using namespace Cantera;
25
26//! @cond
27//! Cabinet type definitions will be ignored by Doxygen
28
29// Define Cabinet<Func1> (single-instance object)
30typedef Cabinet<Func1> Func1Cabinet;
31template<> Func1Cabinet* Func1Cabinet::s_storage = 0; // initialized here
32
33//! @endcond
34
35extern "C" {
36
37 int32_t func1_checkFunc1(const char* func1Type, int32_t bufLen, char* buf)
38 {
39 // function: string checkFunc1(const string&)
40 try {
41 string out = checkFunc1(func1Type);
42 copyString(out, buf, bufLen);
43 return int(out.size()) + 1;
44 } catch (...) {
45 return handleAllExceptions(-1, ERR);
46 }
47 }
48
49 int32_t func1_newBasic(const char* func1Type, double coeff)
50 {
51 // constructor: shared_ptr<Func1> newFunc1(const string&, double)
52 try {
53 return Func1Cabinet::add(newFunc1(func1Type, coeff));
54 } catch (...) {
55 return handleAllExceptions(-2, ERR);
56 }
57 }
58
59 int32_t func1_newAdvanced(const char* func1Type, int32_t arrLen, const double* arr)
60 {
61 // constructor: shared_ptr<Func1> newFunc1(const string&, const vector<double>&)
62 try {
63 const vector<double> arr_(arr, arr + arrLen);
64 return Func1Cabinet::add(newFunc1(func1Type, arr_));
65 } catch (...) {
66 return handleAllExceptions(-2, ERR);
67 }
68 }
69
70 int32_t func1_newCompound(const char* func1Type, const int32_t f1, const int32_t f2)
71 {
72 // constructor: shared_ptr<Func1> newFunc1(const string&, const shared_ptr<Func1>, const shared_ptr<Func1>)
73 try {
74 return Func1Cabinet::add(newFunc1(func1Type, Func1Cabinet::at(f1), Func1Cabinet::at(f2)));
75 } catch (...) {
76 return handleAllExceptions(-2, ERR);
77 }
78 }
79
80 int32_t func1_newModified(const char* func1Type, const int32_t f, double coeff)
81 {
82 // constructor: shared_ptr<Func1> newFunc1(const string&, const shared_ptr<Func1>, double)
83 try {
84 return Func1Cabinet::add(newFunc1(func1Type, Func1Cabinet::at(f), coeff));
85 } catch (...) {
86 return handleAllExceptions(-2, ERR);
87 }
88 }
89
90 int32_t func1_newSumFunction(int32_t f1, int32_t f2)
91 {
92 // constructor: shared_ptr<Func1> newSumFunction(shared_ptr<Func1>, shared_ptr<Func1>)
93 try {
94 return Func1Cabinet::add(newSumFunction(Func1Cabinet::at(f1), Func1Cabinet::at(f2)));
95 } catch (...) {
96 return handleAllExceptions(-2, ERR);
97 }
98 }
99
100 int32_t func1_newDiffFunction(int32_t f1, int32_t f2)
101 {
102 // constructor: shared_ptr<Func1> newDiffFunction(shared_ptr<Func1>, shared_ptr<Func1>)
103 try {
104 return Func1Cabinet::add(newDiffFunction(Func1Cabinet::at(f1), Func1Cabinet::at(f2)));
105 } catch (...) {
106 return handleAllExceptions(-2, ERR);
107 }
108 }
109
110 int32_t func1_newProdFunction(int32_t f1, int32_t f2)
111 {
112 // constructor: shared_ptr<Func1> newProdFunction(shared_ptr<Func1>, shared_ptr<Func1>)
113 try {
114 return Func1Cabinet::add(newProdFunction(Func1Cabinet::at(f1), Func1Cabinet::at(f2)));
115 } catch (...) {
116 return handleAllExceptions(-2, ERR);
117 }
118 }
119
120 int32_t func1_newRatioFunction(int32_t f1, int32_t f2)
121 {
122 // constructor: shared_ptr<Func1> newRatioFunction(shared_ptr<Func1>, shared_ptr<Func1>)
123 try {
124 return Func1Cabinet::add(newRatioFunction(Func1Cabinet::at(f1), Func1Cabinet::at(f2)));
125 } catch (...) {
126 return handleAllExceptions(-2, ERR);
127 }
128 }
129
130 int32_t func1_type(int32_t handle, int32_t bufLen, char* buf)
131 {
132 // getter: virtual string Func1::type()
133 try {
134 string out = Func1Cabinet::at(handle)->type();
135 copyString(out, buf, bufLen);
136 return int(out.size()) + 1;
137 } catch (...) {
138 return handleAllExceptions(-1, ERR);
139 }
140 }
141
142 double func1_eval(int32_t handle, double t)
143 {
144 // method: virtual double Func1::eval(double)
145 try {
146 return Func1Cabinet::at(handle)->eval(t);
147 } catch (...) {
148 return handleAllExceptions(DERR, DERR);
149 }
150 }
151
152 int32_t func1_derivative(int32_t handle)
153 {
154 // accessor: virtual shared_ptr<Func1> Func1::derivative()
155 try {
156 return Func1Cabinet::add(Func1Cabinet::at(handle)->derivative());
157 } catch (...) {
158 return handleAllExceptions(-2, ERR);
159 }
160 }
161
162 int32_t func1_write(int32_t handle, const char* arg, int32_t bufLen, char* buf)
163 {
164 // method: virtual string Func1::write(const string&)
165 try {
166 string out = Func1Cabinet::at(handle)->write(arg);
167 copyString(out, buf, bufLen);
168 return int(out.size()) + 1;
169 } catch (...) {
170 return handleAllExceptions(-1, ERR);
171 }
172 }
173
174 int32_t func1_del(int32_t handle)
175 {
176 // destructor
177 try {
178 Func1Cabinet::del(handle);
179 return 0;
180 } catch (...) {
181 return handleAllExceptions(-1, ERR);
182 }
183 }
184
186 {
187 // reserved CLib function: custom code
188 try {
189 // *************** begin custom code ***************
190 return Func1Cabinet::size();
191 // **************** end custom code ****************
192 } catch (...) {
193 return handleAllExceptions(-1, ERR);
194 }
195 }
196
197} // extern "C"
int32_t func1_newDiffFunction(int32_t f1, int32_t f2)
Difference of two functions.
Definition ctfunc.cpp:100
int32_t func1_newRatioFunction(int32_t f1, int32_t f2)
Ratio of two functions.
Definition ctfunc.cpp:120
int32_t func1_type(int32_t handle, int32_t bufLen, char *buf)
Returns a string describing the type of the function.
Definition ctfunc.cpp:130
int32_t func1_checkFunc1(const char *func1Type, int32_t bufLen, char *buf)
Check definition of functor object.
Definition ctfunc.cpp:37
int32_t func1_newProdFunction(int32_t f1, int32_t f2)
Product of two functions.
Definition ctfunc.cpp:110
double func1_eval(int32_t handle, double t)
Evaluate the function.
Definition ctfunc.cpp:142
int32_t func1_newSumFunction(int32_t f1, int32_t f2)
Sum of two functions.
Definition ctfunc.cpp:90
int32_t func1_newModified(const char *func1Type, const int32_t f, double coeff)
Create a new modified functor object (see Modified Functors).
Definition ctfunc.cpp:80
int32_t func1_newAdvanced(const char *func1Type, int32_t arrLen, const double *arr)
Create a new advanced functor object (see Advanced Functors).
Definition ctfunc.cpp:59
int32_t func1_newBasic(const char *func1Type, double coeff)
Create a new basic functor object (see Basic Functors).
Definition ctfunc.cpp:49
int32_t func1_del(int32_t handle)
Delete Func1 object.
Definition ctfunc.cpp:174
int32_t func1_derivative(int32_t handle)
Creates a derivative to the current function.
Definition ctfunc.cpp:152
int32_t func1_write(int32_t handle, const char *arg, int32_t bufLen, char *buf)
Write LaTeX string describing function.
Definition ctfunc.cpp:162
int32_t func1_cabinetSize()
Return size of Func1 storage.
Definition ctfunc.cpp:185
int32_t func1_newCompound(const char *func1Type, const int32_t f1, const int32_t f2)
Create a new compound functor object (see Compound Functors).
Definition ctfunc.cpp:70
size_t copyString(const string &source, char *dest, size_t length)
Copy the contents of a string into a char array of a given length.
shared_ptr< Func1 > newFunc1(const string &func1Type, double coeff)
Create a new basic functor object (see Basic Functors).
string checkFunc1(const string &func1Type)
Check definition of functor object.
shared_ptr< Func1 > newProdFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Product of two functions.
Definition Func1.cpp:653
shared_ptr< Func1 > newDiffFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Difference of two functions.
Definition Func1.cpp:629
shared_ptr< Func1 > newSumFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Sum of two functions.
Definition Func1.cpp:602
shared_ptr< Func1 > newRatioFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Ratio of two functions.
Definition Func1.cpp:706
CTFUNC - Generated CLib Cantera interface library.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Definition clib_utils.h:32
Contains declarations for string manipulation functions within Cantera.