mbxmlutils  1.3.0
Multi-Body XML Utils
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 
20 
21 Eval::Value C(const octave_value &value);
22 
23 class OctEval;
24 
26 class OctEval : public Eval {
27  friend class Eval;
28 
29  protected:
31  OctEval(std::vector<boost::filesystem::path> *dependencies_=nullptr);
32 
33  public:
35  ~OctEval() override;
36 
38  static std::string getNameStatic() { return "octave"; }
39  std::string getName() const override { return getNameStatic(); }
40 
45  void addImport(const std::string &code, const xercesc::DOMElement *e) override;
46 
47  void addImportHelper(const boost::filesystem::path &dir);
48 
50  bool valueIsOfType(const Value &value, ValueType type) const override;
51 
53  std::map<boost::filesystem::path, std::pair<boost::filesystem::path, bool> >& requiredFiles() const override;
54 
55  void convertIndex(Value &v, bool evalTo1Based) override {}
56 
57  protected:
58 
59  struct Import {
60  std::string path;
61  std::map<std::string, octave_value> vn;
62  std::map<std::string, octave_value> gvn;
63  std::map<std::string, octave_value> ufn;
64  std::map<std::string, octave_value> tlvn;
65  };
66 
67  Value createFunctionIndep(int dim) const override;
68 
70  Value fullStringToValue(const std::string &str, const xercesc::DOMElement *e) const override;
71 
72  static octave_value_list fevalThrow(octave_function *func, const octave_value_list &arg, int n=0,
73  const std::string &msg=std::string());
74 
75  static void* getSwigPtr(const octave_value &v);
76  static Value createSwigByTypeName(const std::string &name);
77  static std::string getSwigType(const octave_value &value);
78 
79  Value callFunction(const std::string &name, const std::vector<Value>& args) const override;
80 
81  double cast_double (const Value &value) const override;
82  std::vector<double> cast_vector_double (const Value &value) const override;
83  std::vector<std::vector<double> > cast_vector_vector_double(const Value &value) const override;
84  std::string cast_string (const Value &value) const override;
85 
86  Value create_double (const double& v) const override;
87  Value create_vector_double (const std::vector<double>& v) const override;
88  Value create_vector_vector_double (const std::vector<std::vector<double> >& v) const override;
89  Value create_string (const std::string& v) const override;
90 
91  Value createFunctionDep(const std::vector<Value>& v) const override;
92  Value createFunctionDep(const std::vector<std::vector<Value> >& v) const override;
93  Value createFunction(const std::vector<Value> &indeps, const Value &dep) const override;
94 
95  std::string serializeFunction(const Value &x) const override;
96 };
97 
98 } // end namespace MBXMLUtils
99 
100 #endif
Value callFunction(const std::string &name, const std::vector< Value > &args) const override
Definition: octeval.cc:647
Definition: eval.h:76
Definition: octeval.h:26
void convertIndex(Value &v, bool evalTo1Based) override
Definition: octeval.h:55
Value createFunctionDep(const std::vector< Value > &v) const override
create a vector function dependent
~OctEval() override
Destructor.
std::string getName() const override
Get the type of this evaluator.
Definition: octeval.h:39
std::ostream & msg(MsgType type) const
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:282
Value fullStringToValue(const std::string &str, const xercesc::DOMElement *e) const override
evaluate str fully and return result as an octave variable
Definition: octeval.cc:444
Definition: octeval.h:59
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:599
OctEval(std::vector< boost::filesystem::path > *dependencies_=nullptr)
Constructor.
Definition: octeval.cc:352
bool valueIsOfType(const Value &value, ValueType type) const override
get the type of value
Definition: octeval.cc:550
void addImport(const std::string &code, const xercesc::DOMElement *e) override
Definition: octeval.cc:421
std::shared_ptr< void > Value
Typedef for a shared value.
Definition: eval.h:91
Value createFunctionIndep(int dim) const override
create a function independent variable. If dim == 0 a scalar is created else a vector.
Definition: octeval.cc:363
static std::string getNameStatic()
Get the name of this evaluator.
Definition: octeval.h:38
ValueType
Definition: eval.h:82