Skip to content
Snippets Groups Projects
Commit 20630795 authored by Andrea Dell'Acqua's avatar Andrea Dell'Acqua
Browse files

Switch GMX to use Partow's expression evaluator instead of CLHEP

parent 3c227929
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,21 @@ class IEvaluator {
*/
~IEvaluator() {;}
enum {
OK, /**< Everything OK */
WARNING_EXISTING_VARIABLE, /**< Redefinition of existing variable */
WARNING_EXISTING_FUNCTION, /**< Redefinition of existing function */
WARNING_BLANK_STRING, /**< Empty input string */
ERROR_NOT_A_NAME, /**< Not allowed sysmbol in the name of variable or function */
ERROR_SYNTAX_ERROR, /**< Systax error */
ERROR_UNPAIRED_PARENTHESIS, /**< Unpaired parenthesis */
ERROR_UNEXPECTED_SYMBOL, /**< Unexpected sysbol */
ERROR_UNKNOWN_VARIABLE, /**< Non-existing variable */
ERROR_UNKNOWN_FUNCTION, /**< Non-existing function */
ERROR_EMPTY_PARAMETER, /**< Function call has empty parameter */
ERROR_CALCULATION_ERROR /**< Error during calculation */
};
virtual double evaluate(const char * expression) = 0;
virtual int status() const {return 0;}
......
......@@ -51,7 +51,7 @@ XERCES_CPP_NAMESPACE_BEGIN
class DOMNode;
XERCES_CPP_NAMESPACE_END
class Evaluator;
class IEvaluator;
class Gmx2Geo {
public:
......@@ -61,7 +61,7 @@ private:
Gmx2Geo(const Gmx2Geo &right);
Gmx2Geo & operator=(const Gmx2Geo &right);
int doDefines(xercesc::DOMDocument *doc, Evaluator &eval);
int doDefines(xercesc::DOMDocument *doc, IEvaluator &eval);
int doPositionIndex(xercesc::DOMDocument *doc, GmxUtil &gmxUtil);
int doReadoutGeometry(xercesc::DOMDocument *doc, GmxUtil &gmxUtil);
void addParam(xercesc::DOMNode *node, std::map<std::string, std::string> &params);
......
......@@ -9,11 +9,9 @@
// to element handlers instead of a (changing??) list.
//
#include <string>
#ifndef STANDALONE_GMX
#include "CLHEP/Evaluator/Evaluator.h"
#else
#include "ExpressionEvaluator/Evaluator.h"
#endif
#include "ExpressionEvaluator/ExprtkEvaluator.h"
#include "GeoModelXml/MaterialManager.h"
#include "GeoModelXml/ProcessorRegistry.h"
#include "GeoModelXml/Element2GeoItemRegistry.h"
......@@ -38,9 +36,7 @@
#include "GeoModelXml/MakeTransformationref.h"
#include "GeoModelXml/MakeTranslation.h"
#include "GeoModelXml/MakeRotation.h"
#ifndef STANDALONE_GMX
#include "GeoModelXml/MakeScaling.h"
#endif
// #include "GeoModelXml/MakeScaling.h"
#include "GeoModelXml/shape/MakeSimplePolygonBrep.h"
#include "GeoModelXml/shape/MakeEllipticalTube.h"
......@@ -73,11 +69,9 @@ public:
GmxInterface *gmxInterface();
double evaluate(char const *expression);
std::string debracket(std::string expression);
#ifndef STANDALONE_GMX
HepTool::Evaluator eval;
#else
Evaluator eval;
#endif
ExprtkEvaluator eval;
PositionIndex positionIndex;
MaterialManager* matManager=0;
ProcessorRegistry processorRegistry;
......
......@@ -20,7 +20,7 @@
#include <map>
#include <string>
class Evaluator;
class IEvaluator;
class PositionIndex {
public:
......@@ -39,7 +39,7 @@ public:
std::string formula(std::string name);
void setFormula(std::string name, std::string formula);
void indices(std::map<std::string, int> &index, Evaluator &eval);
void indices(std::map<std::string, int> &index, IEvaluator &eval);
private:
int m_level;
......
......@@ -104,7 +104,7 @@ Gmx2Geo::Gmx2Geo(const string xmlFile, GeoPhysVol *addHere, GmxInterface &gmxInt
XMLPlatformUtils::Terminate();
}
int Gmx2Geo::doDefines(DOMDocument *doc, Evaluator &eval) {
int Gmx2Geo::doDefines(DOMDocument *doc, IEvaluator &eval) {
//
// Add all defines to the CLHEP::Evaluator
//
......
......@@ -117,7 +117,7 @@ double GmxUtil::evaluate(char const *expression) {
#ifndef STANDALONE_GMX
if (eval.status() != HepTool::Evaluator::OK) {
#else
if (eval.status() != Evaluator::OK) {
if (eval.status() != IEvaluator::OK) {
#endif
#ifndef STANDALONE_GMX
msglog << MSG::FATAL << "GeoModelXml Error processing Evaluator expression. Error name <" <<
......
......@@ -68,7 +68,7 @@ void PositionIndex::setFormula(std::string name, std::string formula) {
m_formula[name] = formula;
}
void PositionIndex::indices(map<string, int> &index, Evaluator &eval) {
void PositionIndex::indices(map<string, int> &index, IEvaluator &eval) {
index.clear(); // In case caller uses it many times
//
// Set Copy Number of each Level (CNL_i) up to current level
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment