26 #ifndef CASADI_IMPORTER_HPP
27 #define CASADI_IMPORTER_HPP
29 #include "function.hpp"
30 #include "printable.hpp"
39 T text2type(
const std::string& text) {
40 std::istringstream ss(text);
50 std::vector<T> text2vector(
const std::string& text) {
51 std::istringstream ss(text);
54 while (ss >> tmp) ret.push_back(tmp);
62 std::set<T> text2set(
const std::string& text) {
63 std::vector<T> v = text2vector<T>(text);
65 for (
auto&& i : v) ret.insert(i);
71 class ImporterInternal;
86 public SWIG_IF_ELSE(PrintableCommon, Printable<Importer>) {
98 const std::string& compiler,
115 static std::string
doc(
const std::string& name);
125 signal_t get_function(
const std::string& symname);
133 static Importer create(ImporterInternal* node);
138 static Importer create(ImporterInternal* node,
const Dict& opts);
145 bool has_meta(
const std::string& cmd, casadi_int ind=-1)
const;
150 std::string
get_meta(
const std::string& cmd, casadi_int ind=-1)
const;
153 bool inlined(
const std::string& symname)
const;
156 std::string
body(
const std::string& symname)
const;
163 static inline std::string indexed(
const std::string& cmd, casadi_int ind) {
164 std::stringstream ss;
165 ss << cmd <<
"[" << ind <<
"]";
173 T to(
const std::string& cmd, casadi_int ind=-1)
const {
174 return text2type<T>(get_meta(cmd, ind));
180 std::string meta_string(
const std::string& cmd, casadi_int ind=-1)
const {
181 return to<std::string>(cmd, ind);
188 std::vector<T> meta_vector(
const std::string& cmd, casadi_int ind=-1)
const {
189 return text2vector<T>(get_meta(cmd, ind));
196 std::set<T> meta_set(
const std::string& cmd, casadi_int ind=-1)
const {
197 return text2set<T>(get_meta(cmd, ind));
203 casadi_int meta_int(
const std::string& cmd, casadi_int ind=-1)
const {
204 return to<casadi_int>(cmd, ind);
Helper class for Serialization.
static Importer deserialize(DeserializingStream &s)
Deserialize with type disambiguation.
std::string library() const
Get library name.
Importer(const std::string &name, const std::string &compiler, const Dict &opts=Dict())
Importer factory.
std::string body(const std::string &symname) const
Get the function body, if inlined.
ImporterInternal * operator->()
Access functions of the node.
void serialize(SerializingStream &s) const
Serialize an object.
static bool test_cast(const SharedObjectInternal *ptr)
Check if a particular cast is allowed.
Importer()
Default constructor.
bool has_meta(const std::string &cmd, casadi_int ind=-1) const
Does a meta entry exist?
std::string get_meta(const std::string &cmd, casadi_int ind=-1) const
Get entry as a text.
static std::string type_name()
Get type name.
static void load_plugin(const std::string &name)
Explicitly load a plugin dynamically.
static std::string doc(const std::string &name)
Get solver specific documentation.
static bool has_plugin(const std::string &name)
Check if a plugin is available.
bool has_function(const std::string &symname) const
std::string plugin_name() const
Query plugin name.
bool inlined(const std::string &symname) const
Check if a function is inlined.
const ImporterInternal * operator->() const
Helper class for Serialization.
SharedObject implements a reference counting framework similar for efficient and.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.