#include <eval.h>
Public Types | |
enum | ValueType { ScalarType, VectorType, MatrixType, StringType, SXFunctionType } |
![]() | |
enum | MsgType |
Public Member Functions | |
~Eval () | |
Destructor. | |
virtual std::string | getName () const =0 |
Get the type of this evaluator. | |
void | addParam (const std::string ¶mName, const boost::shared_ptr< void > &value) |
Add a value to the current parameters. | |
void | addParamSet (const xercesc::DOMElement *e) |
virtual void | addImport (const std::string &code, const xercesc::DOMElement *e, bool deprecated=false)=0 |
boost::shared_ptr< void > | eval (const xercesc::DOMElement *e) |
boost::shared_ptr< void > | eval (const xercesc::DOMAttr *a, const xercesc::DOMElement *pe=NULL) |
template<typename T > | |
T | cast (const boost::shared_ptr< void > &value, xercesc::DOMDocument *doc) const |
template<typename T > | |
T | cast (const boost::shared_ptr< void > &value) const |
see cast(const boost::shared_ptr<void> &value, shared_ptr<DOMDocument> &doc) | |
virtual bool | valueIsOfType (const boost::shared_ptr< void > &value, ValueType type) const =0 |
boost::shared_ptr< void > | stringToValue (const std::string &str, const xercesc::DOMElement *e=NULL, bool fullEval=true) const |
template<class T > | |
boost::shared_ptr< void > | create (const T &v) const |
create a value of the given type | |
virtual std::map < boost::filesystem::path, std::pair < boost::filesystem::path, bool > > & | requiredFiles () const =0 |
return a list of all required files of the evaluator (excluding dependent files of libraries) | |
virtual bool | useOneBasedIndexes ()=0 |
Return true if the evaluator used one based indexes or false if zero based indexes are used. | |
template<> | |
string | cast (const shared_ptr< void > &value) const |
template<> | |
CodeString | cast (const shared_ptr< void > &value) const |
template<> | |
double | cast (const shared_ptr< void > &value) const |
template<> | |
int | cast (const shared_ptr< void > &value) const |
template<> | |
vector< double > | cast (const shared_ptr< void > &value) const |
template<> | |
vector< vector< double > > | cast (const shared_ptr< void > &value) const |
template<> | |
DOMElement * | cast (const shared_ptr< void > &value, xercesc::DOMDocument *doc) const |
template<> | |
shared_ptr< void > | create (const double &v) const |
template<> | |
shared_ptr< void > | create (const vector< double > &v) const |
template<> | |
shared_ptr< void > | create (const vector< vector< double > > &v) const |
template<> | |
shared_ptr< void > | create (const string &v) const |
template<> | |
CodeString | cast (const boost::shared_ptr< void > &value) const |
template<> | |
double | cast (const boost::shared_ptr< void > &value) const |
template<> | |
int | cast (const boost::shared_ptr< void > &value) const |
template<> | |
boost::shared_ptr< void > | create (const double &v) const |
![]() | |
Atom & | operator= (const Atom &) |
void | setMessageStreamActive (MsgType type, bool active) |
void | getMessageStream (MsgType type, boost::shared_ptr< bool > &a, boost::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 boost::shared_ptr< Eval > | createEvaluator (const std::string &evalName, std::vector< boost::filesystem::path > *dependencies_=NULL) |
Create a evaluator. | |
template<class E > | |
static void | registerEvaluator () |
![]() | |
static void | setCurrentMessageStream (MsgType type, const boost::shared_ptr< bool > &a=boost::make_shared< bool >(true), const boost::shared_ptr< std::ostream > &s=boost::make_shared< std::ostream >(std::cout.rdbuf())) |
static std::ostream & | msgStatic (MsgType type) |
static bool | msgActStatic (MsgType type) |
Protected Member Functions | |
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 > | |
boost::shared_ptr< void > | createSwig () const |
virtual boost::shared_ptr< void > | createSwigByTypeName (const std::string &typeName) const =0 |
create a SWIG object of name typeName. | |
virtual boost::shared_ptr< void > | callFunction (const std::string &name, const std::vector< boost::shared_ptr< void > > &args) const =0 |
virtual boost::shared_ptr< void > | fullStringToValue (const std::string &str, const xercesc::DOMElement *e=NULL) const =0 |
evaluate the string str using the current parameters and return the result. | |
std::string | partialStringToString (const std::string &str, const xercesc::DOMElement *e) const |
evaluate str partially and return result as an std::string | |
virtual void * | getSwigThis (const boost::shared_ptr< void > &value) const =0 |
get the SWIG pointer of this value. | |
virtual std::string | getSwigType (const boost::shared_ptr< void > &value) const =0 |
get the SWIG type (class name) of this value. | |
void | addStaticDependencies (const xercesc::DOMElement *e) const |
![]() | |
Atom (const Atom &src) | |
Static Protected Member Functions | |
template<class E > | |
static boost::shared_ptr< Eval > | newEvaluator (std::vector< boost::filesystem::path > *dependencies_) |
Static Protected Attributes | |
static boost::shared_ptr< void > | casadiValue |
Private Member Functions | |
virtual double | cast_double (const boost::shared_ptr< void > &value) const =0 |
virtual std::vector< double > | cast_vector_double (const boost::shared_ptr< void > &value) const =0 |
virtual std::vector < std::vector< double > > | cast_vector_vector_double (const boost::shared_ptr< void > &value) const =0 |
virtual std::string | cast_string (const boost::shared_ptr< void > &value) const =0 |
CodeString | cast_CodeString (const boost::shared_ptr< void > &value) const |
int | cast_int (const boost::shared_ptr< void > &value) const |
xercesc::DOMElement * | cast_DOMElement_p (const boost::shared_ptr< void > &value, xercesc::DOMDocument *doc) const |
virtual boost::shared_ptr< void > | create_double (const double &v) const =0 |
virtual boost::shared_ptr< void > | create_vector_double (const std::vector< double > &v) const =0 |
virtual boost::shared_ptr< void > | create_vector_vector_double (const std::vector< std::vector< double > > &v) const =0 |
virtual boost::shared_ptr< void > | create_string (const std::string &v) const =0 |
boost::shared_ptr< void > | handleUnit (const xercesc::DOMElement *e, const boost::shared_ptr< void > &ret) |
Static Private Member Functions | |
static std::map< std::string, boost::function < boost::shared_ptr< Eval > std::vector < boost::filesystem::path > *)> > & | getEvaluators () |
Static Private Attributes | |
static std::map< std::string, std::string > | units |
Friends | |
class | NewParamLevel |
Expression evaluator and converter.
Known types for a variable See also valueIsOfType.
|
pure virtual |
Import evaluator statements. This routine highly depends on the evaluator. See the spezialized evaluators documentation for details.
Implemented in MBXMLUtils::OctEval, MBXMLUtils::PyEval, and MBXMLUtils::XMLFlatEval.
void MBXMLUtils::Eval::addParamSet | ( | const xercesc::DOMElement * | e | ) |
Add all parameters from XML element e. The parameters are added from top to bottom as they appear in the XML element e. Parameters may depend on parameters already added.
|
protectedpure virtual |
Return the value of a call to name using the arguments args. The following functions must be implemented by the evaluator:
Implemented in MBXMLUtils::OctEval, MBXMLUtils::PyEval, and MBXMLUtils::XMLFlatEval.
T MBXMLUtils::Eval::cast | ( | const boost::shared_ptr< void > & | value, |
xercesc::DOMDocument * | doc | ||
) | const |
Cast the value value to type T
. Possible combinations of allowed value types and template types T
are listed in the following table. If a combination is not allowed a exception is thrown. If a c-pointer is returned this c-pointer is only guaranteed to be valid for the lifetime of the object value
being passed as argument. If a DOMElement* is returned doc
must be given and ownes the memory of the returned DOM tree. For other return types this function must be called with only one argument cast(const boost::shared_ptr<void> &value);
value is of Type ... | ||||||
---|---|---|---|---|---|---|
Template Type T equals ... | real scalar | real vector | real matrix | string | SWIG casadi::SXFunction | SWIG |
int | only if its integral number | |||||
double | X | |||||
vector<double> | X | X | ||||
vector<vector<double> > | X | X | X | |||
string | X | |||||
CodeString | returns e.g. 5 | returns e.g. [3;7] | returns e.g. [1,3;5,4] | returns e.g. 'foo' | ||
DOMElement* | X | |||||
casadi::SXFunction* | X | |||||
XYZ* | * |
For arbitary evaluator values of type SWIG wrapper object (see * in table) a instantiation of template<> string SwigType<XYZ*>::name("<swig_type_name_of_XYZ>");
is required. Eval instantiates this for casadi::SX and casadi::SXFunction.
boost::shared_ptr<void> MBXMLUtils::Eval::eval | ( | const xercesc::DOMElement * | e | ) |
Evaluate the XML element e using the current parameters returning the resulting value. The type of evaluation depends on the type of e.
shared_ptr< void > MBXMLUtils::Eval::eval | ( | const xercesc::DOMAttr * | a, |
const xercesc::DOMElement * | pe = NULL |
||
) |
Evaluate the XML attribute a using the current parameters returning the resulting value. The type of evaluation depends on the type of a. The result of a "partially" evaluation is returned as a string even so it is not really a string.
shared_ptr< void > MBXMLUtils::Eval::stringToValue | ( | const std::string & | str, |
const xercesc::DOMElement * | e = NULL , |
||
bool | fullEval = true |
||
) | const |
evaluate str and return result as an variable, this can be used to evaluate outside of XML. If e is given it is used as location information in case of errors. If fullEval is false the "partially" evaluation is returned as a string even so it is not really a string.
|
pure 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.
Implemented in MBXMLUtils::OctEval, MBXMLUtils::PyEval, and MBXMLUtils::XMLFlatEval.