mbxmlutils  1.3.0
Multi-Body XML Utils
 All Classes Functions Typedefs Enumerations
octeval.h
1 #ifndef _MBXMLUTILS_OCTEVAL_H_
2 #define _MBXMLUTILS_OCTEVAL_H_
3 
4 #include "eval.h"
5 #include <memory>
6 
7 class octave_value;
8 class octave_value_list;
9 class octave_function;
10 
11 namespace fmatvec {
12  class SymbolicExpression;
13 }
14 
15 namespace XERCES_CPP_NAMESPACE { class DOMElement; }
16 
17 namespace MBXMLUtils {
18 
19 std::shared_ptr<octave_value> C(const Eval::Value &value);
20 
21 Eval::Value C(const octave_value &value);
22 
23 class OctEval;
24 
29 class OctEval : public Eval {
30  friend class Eval;
31 
32  protected:
34  OctEval(std::vector<boost::filesystem::path> *dependencies_=nullptr);
35 
36  public:
38  ~OctEval() override;
39 
41  static std::string getNameStatic() { return "octave"; }
42  std::string getName() const override { return getNameStatic(); }
43 
48  void addImport(const std::string &code, const xercesc::DOMElement *e) override;
49 
50  void addImportHelper(const boost::filesystem::path &dir);
51 
53  bool valueIsOfType(const Value &value, ValueType type) const override;
54 
56  std::map<boost::filesystem::path, std::pair<boost::filesystem::path, bool> >& requiredFiles() const override;
57 
58  void convertIndex(Value &v, bool evalTo1Based) override {}
59 
60  protected:
61 
62  struct Import {
63  std::string path;
64  std::map<std::string, octave_value> vn;
65  std::map<std::string, octave_value> gvn;
66  std::map<std::string, octave_value> ufn;
67  std::map<std::string, octave_value> tlvn;
68  };
69 
70  Value createFunctionIndep(int dim) const override;
71 
73  Value fullStringToValue(const std::string &str, const xercesc::DOMElement *e, bool skipRet=false) const override;
74 
75  static octave_value_list fevalThrow(octave_function *func, const octave_value_list &arg, int n=0,
76  const std::string &msg=std::string());
77 
78  static void* getSwigPtr(const octave_value &v);
79  static Value createSwigByTypeName(const std::string &name);
80  static std::string getSwigType(const octave_value &value);
81 
82  Value callFunction(const std::string &name, const std::vector<Value>& args) const override;
83 
84  double cast_double (const Value &value) const override;
85  std::vector<double> cast_vector_double (const Value &value) const override;
86  std::vector<std::vector<double> > cast_vector_vector_double(const Value &value) const override;
87  std::string cast_string (const Value &value) const override;
88 
89  Value create_double (const double& v) const override;
90  Value create_vector_double (const std::vector<double>& v) const override;
91  Value create_vector_vector_double (const std::vector<std::vector<double> >& v) const override;
92  Value create_string (const std::string& v) const override;
93 
94  Value createFunctionDep(const std::vector<Value>& v) const override;
95  Value createFunctionDep(const std::vector<std::vector<Value> >& v) const override;
96  Value createFunction(const std::vector<Value> &indeps, const Value &dep) const override;
97 
98  std::string serializeFunction(const Value &x) const override;
99 };
100 
101 } // end namespace MBXMLUtils
102 
103 #endif
Value callFunction(const std::string &name, const std::vector< Value > &args) const override
Definition: octeval.cc:797
Definition: eval.h:76
Definition: octeval.h:29
Value createFunctionDep(const std::vector< Value > &v) const override
create a vector function dependent
Definition: octeval.cc:281
Value fullStringToValue(const std::string &str, const xercesc::DOMElement *e, bool skipRet=false) const override
evaluate str fully and return result as an octave variable
Definition: octeval.cc:493
void convertIndex(Value &v, bool evalTo1Based) override
Definition: octeval.h:58
std::map< boost::filesystem::path, std::pair< boost::filesystem::path, bool > > & requiredFiles() const override
return a list of all required files of octave (excluding dependent files of libraries) ...
Definition: octeval.cc:749
~OctEval() override
Destructor.
std::string getName() const override
Get the type of this evaluator.
Definition: octeval.h:42
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: octeval.cc:315
Definition: octeval.h:62
OctEval(std::vector< boost::filesystem::path > *dependencies_=nullptr)
Constructor.
Definition: octeval.cc:385
bool valueIsOfType(const Value &value, ValueType type) const override
get the type of value
Definition: octeval.cc:667
void addImport(const std::string &code, const xercesc::DOMElement *e) override
Definition: octeval.cc:468
Value createFunctionIndep(int dim) const override
create a function independent variable. If dim == 0 a scalar is created else a vector.
Definition: octeval.cc:396
std::shared_ptr< void > Value
Typedef for a shared value.
Definition: eval.h:91
static std::string getNameStatic()
Get the name of this evaluator.
Definition: octeval.h:41
ValueType
Definition: eval.h:82