mbxmlutils  1.3.0
Multi-Body XML Utils
pyeval.h
1 #ifndef _MBXMLUTILS_PYEVAL_H_
2 #define _MBXMLUTILS_PYEVAL_H_
3 
4 #include "eval.h"
5 #include "pycppwrapper.h"
6 
7 namespace MBXMLUtils {
8 
10 class PyEval : public Eval {
11  friend class Eval;
12 
13  protected:
15  PyEval(std::vector<boost::filesystem::path> *dependencies_=nullptr);
16  public:
18  ~PyEval() override;
19  static std::string getNameStatic() { return "python"; }
20  std::string getName() const override { return getNameStatic(); }
21  void addImport(const std::string &code, const xercesc::DOMElement *e) override;
22  bool valueIsOfType(const Value &value, ValueType type) const override;
23  std::map<boost::filesystem::path, std::pair<boost::filesystem::path, bool> >& requiredFiles() const override;
24  void convertIndex(Value &v, bool evalTo1Base) override;
25  protected:
26  Value createFunctionIndep(int dim) const override;
27  Value callFunction(const std::string &name, const std::vector<Value>& args) const override;
28  Value fullStringToValue(const std::string &str, const xercesc::DOMElement *e, bool skipRet=false) const override;
29  private:
30  double cast_double (const Value &value) const override;
31  std::vector<double> cast_vector_double (const Value &value) const override;
32  std::vector<std::vector<double> >cast_vector_vector_double (const Value &value) const override;
33  std::string cast_string (const Value &value) const override;
34  Value create_double (const double& v) const override;
35  Value create_vector_double (const std::vector<double>& v) const override;
36  Value create_vector_vector_double (const std::vector<std::vector<double> >& v) const override;
37  Value create_string (const std::string& v) const override;
38 
39  Value createFunctionDep(const std::vector<Value>& v) const override;
40  Value createFunctionDep(const std::vector<std::vector<Value> >& v) const override;
41  Value createFunction(const std::vector<Value> &indeps, const Value &dep) const override;
42 
43  std::string serializeFunction(const Value &x) const override;
44 };
45 
46 }
47 
48 #endif
Value createFunction(const std::vector< Value > &indeps, const Value &dep) const override
create a Function with n independents and a dependent function (scalar, vector or matrix)
Definition: pyeval.cc:547
Definition: eval.h:76
~PyEval() override
Destructor.
Value createFunctionIndep(int dim) const override
create a function independent variable. If dim == 0 a scalar is created else a vector.
Definition: pyeval.cc:170
void addImport(const std::string &code, const xercesc::DOMElement *e) override
Definition: pyeval.cc:207
std::map< boost::filesystem::path, std::pair< boost::filesystem::path, bool > > & requiredFiles() const override
return a list of all required files of the evaluator (excluding dependent files of libraries)
Definition: pyeval.cc:297
PyEval(std::vector< boost::filesystem::path > *dependencies_=nullptr)
Constructor.
Definition: pyeval.cc:164
A evaluator based on python.
Definition: pyeval.h:10
void convertIndex(Value &v, bool evalTo1Base) override
Definition: pyeval.cc:575
Value createFunctionDep(const std::vector< Value > &v) const override
create a vector function dependent
std::string getName() const override
Get the type of this evaluator.
Definition: pyeval.h:20
bool valueIsOfType(const Value &value, ValueType type) const override
Definition: pyeval.cc:271
Value callFunction(const std::string &name, const std::vector< Value > &args) const override
Definition: pyeval.cc:341
std::shared_ptr< void > Value
Typedef for a shared value.
Definition: eval.h:91
Value fullStringToValue(const std::string &str, const xercesc::DOMElement *e, bool skipRet=false) const override
evaluate the string str using the current parameters and return the result.
Definition: pyeval.cc:354
ValueType
Definition: eval.h:82