Cantera  3.2.0a2
Loading...
Searching...
No Matches
ctrxn.cpp
Go to the documentation of this file.
1/**
2 * CTRXN - Generated CLib %Cantera interface library.
3 *
4 * @file ctrxn.cpp
5 *
6 * Generated CLib API for Cantera's Reaction 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/ctrxn.h"
20
23
24using namespace Cantera;
25
26//! @cond
27//! Cabinet type definitions will be ignored by Doxygen
28
29// Define Cabinet<Reaction> (single-instance object)
30typedef Cabinet<Reaction> ReactionCabinet;
31template<> ReactionCabinet* ReactionCabinet::s_storage = 0; // initialized here
32
33//! @endcond
34
35extern "C" {
36
37 int32_t rxn_new()
38 {
39 // constructor: default constructor for Reaction
40 try {
41 return ReactionCabinet::add(make_shared<Reaction>());
42 } catch (...) {
43 return handleAllExceptions(-1, ERR);
44 }
45 }
46
47 int32_t rxn_equation(int32_t handle, int32_t bufLen, char* buf)
48 {
49 // getter: string Reaction::equation()
50 try {
51 string out = ReactionCabinet::at(handle)->equation();
52 copyString(out, buf, bufLen);
53 return int(out.size()) + 1;
54 } catch (...) {
55 return handleAllExceptions(-1, ERR);
56 }
57 }
58
59 int32_t rxn_type(int32_t handle, int32_t bufLen, char* buf)
60 {
61 // getter: string Reaction::type()
62 try {
63 string out = ReactionCabinet::at(handle)->type();
64 copyString(out, buf, bufLen);
65 return int(out.size()) + 1;
66 } catch (...) {
67 return handleAllExceptions(-1, ERR);
68 }
69 }
70
71 int32_t rxn_usesThirdBody(int32_t handle)
72 {
73 // getter: bool Reaction::usesThirdBody()
74 try {
75 bool out = ReactionCabinet::at(handle)->usesThirdBody();
76 return int(out);
77 } catch (...) {
78 return handleAllExceptions(-1, ERR);
79 }
80 }
81
82 int32_t rxn_valid(int32_t handle)
83 {
84 // getter: bool Reaction::valid()
85 try {
86 bool out = ReactionCabinet::at(handle)->valid();
87 return int(out);
88 } catch (...) {
89 return handleAllExceptions(-1, ERR);
90 }
91 }
92
93 int32_t rxn_id(int handle, int32_t bufLen, char* buf)
94 {
95 // variable (getter): variable getter: id
96 try {
97 string out = ReactionCabinet::at(handle)->id;
98 copyString(out, buf, bufLen);
99 return int(out.size()) + 1;
100 } catch (...) {
101 return handleAllExceptions(-1, ERR);
102 }
103 }
104
105 int32_t rxn_setId(int32_t handle, const char* id)
106 {
107 // variable (setter): variable setter: id
108 try {
109 ReactionCabinet::at(handle)->id = id;
110 return 0;
111 } catch (...) {
112 return handleAllExceptions(ERR, ERR);
113 }
114 }
115
116 int32_t rxn_allowNonreactantOrders(int handle)
117 {
118 // variable (getter): variable getter: allow_nonreactant_orders
119 try {
120 bool out = ReactionCabinet::at(handle)->allow_nonreactant_orders;
121 return int(out);
122 } catch (...) {
123 return handleAllExceptions(-1, ERR);
124 }
125 }
126
127 int32_t rxn_setAllowNonreactantOrders(int32_t handle, int32_t allow_nonreactant_orders)
128 {
129 // variable (setter): variable setter: allow_nonreactant_orders
130 try {
131 bool allow_nonreactant_orders_ = (allow_nonreactant_orders != 0);
132 ReactionCabinet::at(handle)->allow_nonreactant_orders = allow_nonreactant_orders_;
133 return 0;
134 } catch (...) {
135 return handleAllExceptions(ERR, ERR);
136 }
137 }
138
139 int32_t rxn_del(int32_t handle)
140 {
141 // destructor
142 try {
143 ReactionCabinet::del(handle);
144 return 0;
145 } catch (...) {
146 return handleAllExceptions(-1, ERR);
147 }
148 }
149
151 {
152 // reserved CLib function: custom code
153 try {
154 // *************** begin custom code ***************
155 return ReactionCabinet::size();
156 // **************** end custom code ****************
157 } catch (...) {
158 return handleAllExceptions(-1, ERR);
159 }
160 }
161
162 int32_t rxn_parentHandle(int32_t handle)
163 {
164 // reserved CLib function: custom code
165 try {
166 // *************** begin custom code ***************
167 return ReactionCabinet::parent(handle);
168 // **************** end custom code ****************
169 } catch (...) {
170 return handleAllExceptions(-1, ERR);
171 }
172 }
173
174} // extern "C"
CTRXN - Generated CLib Cantera interface library.
int32_t rxn_allowNonreactantOrders(int handle)
True if reaction orders can be specified for non-reactant species.
Definition ctrxn.cpp:116
int32_t rxn_id(int handle, int32_t bufLen, char *buf)
An identification string for the reaction, used in some filtering operations.
Definition ctrxn.cpp:93
int32_t rxn_del(int32_t handle)
Delete Reaction object.
Definition ctrxn.cpp:139
int32_t rxn_new()
Instantiate Reaction object using default constructor.
Definition ctrxn.cpp:37
int32_t rxn_parentHandle(int32_t handle)
Return handle to parent of Reaction object.
Definition ctrxn.cpp:162
int32_t rxn_setId(int32_t handle, const char *id)
An identification string for the reaction, used in some filtering operations.
Definition ctrxn.cpp:105
int32_t rxn_valid(int32_t handle)
Get validity flag of reaction.
Definition ctrxn.cpp:82
int32_t rxn_cabinetSize()
Return size of Reaction storage.
Definition ctrxn.cpp:150
int32_t rxn_type(int32_t handle, int32_t bufLen, char *buf)
The type of reaction, including reaction rate information.
Definition ctrxn.cpp:59
int32_t rxn_equation(int32_t handle, int32_t bufLen, char *buf)
The chemical equation for this reaction.
Definition ctrxn.cpp:47
int32_t rxn_usesThirdBody(int32_t handle)
Check whether reaction involves third body collider.
Definition ctrxn.cpp:71
int32_t rxn_setAllowNonreactantOrders(int32_t handle, int32_t allow_nonreactant_orders)
True if reaction orders can be specified for non-reactant species.
Definition ctrxn.cpp:127
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.
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.