All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Friends | List of all members
MBXMLUtils::PyEval Class Reference

A evaluator based on python. More...

#include <pyeval.h>

Inheritance diagram for MBXMLUtils::PyEval:
MBXMLUtils::Eval fmatvec::Atom

Public Member Functions

 ~PyEval ()
 Destructor.
 
virtual std::string getName () const
 Get the type of this evaluator.
 
virtual void addImport (const std::string &code, const xercesc::DOMElement *e)
 
virtual bool valueIsOfType (const Value &value, ValueType type) const
 
virtual std::map
< boost::filesystem::path,
std::pair
< boost::filesystem::path,
bool > > & 
requiredFiles () const
 return a list of all required files of the evaluator (excluding dependent files of libraries)
 
virtual void convertIndex (Value &v, bool evalTo1Based)
 
- Public Member Functions inherited from MBXMLUtils::Eval
 ~Eval ()
 Destructor.
 
 Eval (const Eval &other)=delete
 
 Eval (Eval &&other)=delete
 
Evaloperator= (const Eval &other)=delete
 
Evaloperator= (Eval &&other)=delete
 
void addParam (const std::string &paramName, const Value &value)
 Add a value to the current parameters.
 
void addParamSet (const xercesc::DOMElement *e)
 
Value eval (const xercesc::DOMElement *e)
 
Value eval (const xercesc::DOMAttr *a, const xercesc::DOMElement *pe=NULL)
 
template<typename T >
cast (const Value &value, xercesc::DOMDocument *doc) const
 
template<typename T >
cast (const Value &value) const
 see cast(const Value &value, shared_ptr<DOMDocument> &doc)
 
Value stringToValue (const std::string &str, const xercesc::DOMElement *e=NULL, bool fullEval=true) const
 
template<class T >
Value create (const T &v) const
 create a value of the given type
 
template<>
string cast (const Value &value) const
 
template<>
CodeString cast (const Value &value) const
 
template<>
double cast (const Value &value) const
 
template<>
int cast (const Value &value) const
 
template<>
vector< double > cast (const Value &value) const
 
template<>
SX cast (const Value &value) const
 
template<>
vector< vector< double > > cast (const Value &value) const
 
template<>
DOMElement * cast (const Value &value, xercesc::DOMDocument *doc) const
 
template<>
Eval::Value create (const double &v) const
 
template<>
Eval::Value create (const vector< double > &v) const
 
template<>
Eval::Value create (const vector< vector< double > > &v) const
 
template<>
Eval::Value create (const string &v) const
 
template<>
CodeString cast (const Value &value) const
 
template<>
double cast (const Value &value) const
 
template<>
int cast (const Value &value) const
 
template<>
Eval::Function cast (const Value &value) const
 
template<>
Eval::Value create (const double &v) const
 
- Public Member Functions inherited from fmatvec::Atom
Atomoperator= (const Atom &)
 
void setMessageStreamActive (MsgType type, bool active)
 
void getMessageStream (MsgType type, std::shared_ptr< bool > &a, std::shared_ptr< std::ostream > &s)
 
void adoptMessageStreams (const Atom *src=NULL)
 
std::ostream & msg (MsgType type)
 
bool msgAct (MsgType type)
 

Static Public Member Functions

static std::string getNameStatic ()
 
- Static Public Member Functions inherited from MBXMLUtils::Eval
static std::shared_ptr< EvalcreateEvaluator (const std::string &evalName, std::vector< boost::filesystem::path > *dependencies_=NULL)
 Create a evaluator.
 
template<class E >
static void registerEvaluator ()
 
static void setValue (xercesc::DOMElement *e, const Value &v)
 Set value on DOMElement (is used by Eval::cast)
 
- Static Public Member Functions inherited from fmatvec::Atom
static void setCurrentMessageStream (MsgType type, const std::shared_ptr< bool > &a=std::make_shared< bool >(true), const std::shared_ptr< std::ostream > &s=std::make_shared< std::ostream >(std::cout.rdbuf()))
 
static std::ostream & msgStatic (MsgType type)
 
static bool msgActStatic (MsgType type)
 

Protected Member Functions

 PyEval (std::vector< boost::filesystem::path > *dependencies_=NULL)
 Constructor.
 
virtual Value createSwigByTypeName (const std::string &typeName) const
 create a SWIG object of name typeName.
 
virtual Value callFunction (const std::string &name, const std::vector< Value > &args) const
 
virtual Value fullStringToValue (const std::string &str, const xercesc::DOMElement *e=NULL) const
 evaluate the string str using the current parameters and return the result.
 
virtual void * getSwigThis (const Value &value) const
 get the SWIG pointer of this value.
 
virtual std::string getSwigType (const Value &value) const
 get the SWIG type (class name) of this value.
 
- Protected Member Functions inherited from MBXMLUtils::Eval
 Eval (std::vector< boost::filesystem::path > *dependencies_)
 Constructor.
 
void pushContext ()
 Push the current context to a internal stack.
 
void popContext ()
 Overwrite the current context with the top level context from the internal stack.
 
template<typename T >
Value createSwig () const
 
std::string partialStringToString (const std::string &str, const xercesc::DOMElement *e) const
 evaluate str partially and return result as an std::string
 
void addStaticDependencies (const xercesc::DOMElement *e) const
 
- Protected Member Functions inherited from fmatvec::Atom
 Atom (const Atom &src)
 

Private Member Functions

virtual double cast_double (const Value &value) const
 
virtual std::vector< double > cast_vector_double (const Value &value) const
 
virtual std::vector
< std::vector< double > > 
cast_vector_vector_double (const Value &value) const
 
virtual std::string cast_string (const Value &value) const
 
virtual Value create_double (const double &v) const
 
virtual Value create_vector_double (const std::vector< double > &v) const
 
virtual Value create_vector_vector_double (const std::vector< std::vector< double > > &v) const
 
virtual Value create_string (const std::string &v) const
 

Friends

class Eval
 

Additional Inherited Members

- Public Types inherited from MBXMLUtils::Eval
enum  ValueType {
  ScalarType, VectorType, MatrixType, StringType,
  FunctionType
}
 
typedef std::pair< std::vector
< casadi::SX >, std::vector
< casadi::SX > > 
Function
 Typedef for a shared value.
 
typedef boost::variant
< std::shared_ptr< void >
, Function
Value
 
- Public Types inherited from fmatvec::Atom
enum  MsgType
 
- Static Protected Member Functions inherited from MBXMLUtils::Eval
template<class E >
static std::shared_ptr< EvalnewEvaluator (std::vector< boost::filesystem::path > *dependencies_)
 
- Protected Attributes inherited from MBXMLUtils::Eval
std::vector
< boost::filesystem::path > * 
dependencies
 
std::unordered_map
< std::string, Value > 
currentParam
 
std::stack< std::unordered_map
< std::string, Value > > 
paramStack
 
std::shared_ptr< void > currentImport
 
std::stack< std::shared_ptr
< void > > 
importStack
 
Value casadiValue
 

Detailed Description

A evaluator based on python.

Member Function Documentation

void MBXMLUtils::PyEval::addImport ( const std::string &  code,
const xercesc::DOMElement *  e 
)
virtual

Import evaluator statements. This routine highly depends on the evaluator. See the spezialized evaluators documentation for details.

Implements MBXMLUtils::Eval.

Eval::Value MBXMLUtils::PyEval::callFunction ( const std::string &  name,
const std::vector< Value > &  args 
) const
protectedvirtual

Return the value of a call to name using the arguments args. The following functions must be implemented by the evaluator:

  • rotateAboutX(alpha): returns a 3x3 rotation matrix about the x-axis by angle alpha which is given in rad.
  • rotateAboutY(beta): returns a 3x3 rotation matrix about the y-axis by angle beta which is given in rad.
  • rotateAboutZ(gamma): returns a 3x3 rotation matrix about the z-axis by angle gamma which is given in rad.
  • cardan(alpha, beta, gamma): returns a 3x3 rotation matrix of a cardan rotation about the angles alpha, beta and gamma which are given in rad.
  • euler(PHI, theta, phi): returns a 3x3 rotation matrix of a euler rotation about the angles PHI, theta and phi which are given in rad.
  • load(filename): returns a NxM matrix of the data stored in the file filename. filename may be a absolute or relative path. A relative path is interprete relative to the location of the XML file with the load statement. (The abstract Eval class guarantees that the current path is at the XML file if load is called)

Implements MBXMLUtils::Eval.

void MBXMLUtils::PyEval::convertIndex ( Value &  v,
bool  evalTo1Based 
)
virtual

convert a index (scalar or vector). if evalTo1Based == true: convert from the script language 0/1 base to 1 base. if evalTo1Based == false: convert from 1 base to the script language 0/1 base.

Implements MBXMLUtils::Eval.

bool MBXMLUtils::PyEval::valueIsOfType ( const Value &  value,
ValueType  type 
) const
virtual

check whether value is of type type. Note that true is only returned if the value is really of type type. If value can be casted to type type but is not of this type then false is returned. Note that their are evaluators (e.g. octave) which cannot distinguish between e.g. a scalar, a vector of size 1 or a matrix of size 1x1. Hence, these evaluators will return true for ScalarType in all these three cases and analog for VectorType.

Implements MBXMLUtils::Eval.


The documentation for this class was generated from the following files:

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML