26 #ifndef CASADI_EXTERNAL_IMPL_HPP
27 #define CASADI_EXTERNAL_IMPL_HPP
29 #include "external.hpp"
30 #include "function_internal.hpp"
38 #define _WIN32_WINNT 0x0502
50 class CASADI_EXPORT External :
public FunctionInternal {
65 signal_t incref_, decref_;
70 getint_t get_n_in_, get_n_out_;
75 name_t get_name_in_, get_name_out_;
80 default_t get_default_in_;
91 std::vector<casadi_int> int_data_;
92 std::vector<double> real_data_;
93 std::string string_data_;
99 std::vector<std::string> config_args_;
100 std::vector<const char*> args_;
106 External(
const std::string& name,
const Importer& li,
107 const std::vector<std::string> config_args=std::vector<std::string>());
112 ~External()
override = 0;
117 virtual bool any_symbol_found()
const;
120 Function factory(
const std::string& name,
121 const std::vector<std::string>& s_in,
122 const std::vector<std::string>& s_out,
124 const Dict& opts)
const override;
129 std::string class_name()
const override {
return "External";}
134 virtual void init_external();
137 void init(
const Dict& opts)
override;
142 void codegen_declarations(CodeGenerator& g)
const override;
147 void codegen_body(CodeGenerator& g)
const override;
152 std::string codegen_mem_type()
const override;
157 void codegen_incref(CodeGenerator& g)
const override;
162 void codegen_decref(CodeGenerator& g)
const override;
167 void codegen_checkout(CodeGenerator& g)
const override;
172 void codegen_release(CodeGenerator& g)
const override;
177 void codegen_alloc_mem(CodeGenerator& g)
const override;
182 void codegen_init_mem(CodeGenerator& g)
const override;
187 void codegen_free_mem(CodeGenerator& g)
const override;
193 size_t get_n_in()
override;
194 size_t get_n_out()
override;
200 double get_default_in(casadi_int i)
const override;
206 std::string get_name_in(casadi_int i)
override;
207 std::string get_name_out(casadi_int i)
override;
214 Function get_forward(casadi_int nfwd,
const std::string& name,
215 const std::vector<std::string>& inames,
216 const std::vector<std::string>& onames,
217 const Dict& opts)
const override;
218 bool has_forward(casadi_int nfwd)
const override;
225 Function get_reverse(casadi_int nadj,
const std::string& name,
226 const std::vector<std::string>& inames,
227 const std::vector<std::string>& onames,
228 const Dict& opts)
const override;
229 bool has_reverse(casadi_int nadj)
const override;
236 bool has_jacobian()
const override;
237 Function get_jacobian(
const std::string& name,
238 const std::vector<std::string>& inames,
239 const std::vector<std::string>& onames,
240 const Dict& opts)
const override;
246 void serialize_body(SerializingStream &s)
const override;
251 static ProtoFunction* deserialize(DeserializingStream& s);
256 std::string serialize_base_function()
const override {
return "External"; }
262 explicit External(DeserializingStream& s);
265 class CASADI_EXPORT GenericExternal :
public External {
267 sparsity_t get_sparsity_in_, get_sparsity_out_, get_jac_sparsity_;
269 diff_t get_diff_in_, get_diff_out_;
275 GenericExternal(
const std::string& name,
const Importer& li,
276 const std::vector<std::string> config_args=std::vector<std::string>());
281 ~GenericExternal()
override { this->clear_mem();}
286 bool any_symbol_found()
const override;
291 void init_external()
override;
294 void init(
const Dict& opts)
override;
300 Sparsity get_sparsity_in(casadi_int i)
override;
301 Sparsity get_sparsity_out(casadi_int i)
override;
308 bool has_jac_sparsity(casadi_int oind, casadi_int iind)
const override;
309 Sparsity get_jac_sparsity(casadi_int oind, casadi_int iind,
bool symmetric)
const override;
316 bool get_diff_in(casadi_int i)
override;
317 bool get_diff_out(casadi_int i)
override;
323 void serialize_type(SerializingStream &s)
const override;
328 explicit GenericExternal(DeserializingStream& s);
std::map< std::string, std::vector< std::string > > AuxOut
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.