00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef UAPUtilities_hpp
00025 #define UAPUtilities_hpp 1
00026
00027 #include <cmath>
00028 #include <list>
00029 #include <map>
00030 #include <string>
00031 #include "UAPException.hpp"
00032
00033 class UAPNode;
00034 class UAPAttribute;
00035
00036
00037 #define IA 16807
00038 #define IM 2147483647
00039 #define AM (1.0/IM)
00040 #define IQ 127773
00041 #define IR 2836
00042 #define NTAB 32
00043 #define NDIV (1+(IM-1)/NTAB)
00044 #define EPS 1.2e-7
00045 #define RNMX (1.0-EPS)
00046
00051 class UAPUtilities
00052 {
00053 public:
00054
00059 UAPUtilities(UAPNode* _UAPRootNode);
00060
00062 ~UAPUtilities();
00063
00068 void setUAPRootNode(UAPNode* _UAPRootNode);
00069
00074 UAPNode* getUAPRootNode();
00075
00081 int evaluate();
00082
00090 int evaluate(UAPNode* node, UAPNode* context = 0);
00091
00098 double evaluate(const std::string attrib, UAPNode* context = NULL) throw(UAPParserException);
00099
00100 double evaluate(UAPAttribute&, UAPNode* context = NULL) throw(UAPParserException);
00101
00111 int getParameterValue(UAPNode* node, std::string& param_name, std::string& param_value);
00112
00122 void addConstant(const std::string& name, double value, bool allow_overwrite = false);
00123
00129 int removeConstant(const std::string& name);
00130
00136 std::list<std::string> parseIdentifiers(const std::string& expr) throw(UAPParserException);
00137
00142 double nextGaussian();
00143
00147 double nextDouble();
00148
00149 private:
00150
00152 UAPNode* UAPRootNode;
00153
00155 long seed;
00156
00158 std::map<std::string, double> constants;
00159
00165 float gasdev(long* idum);
00166
00172 float ran1(long* idum);
00173
00174 };
00175
00176 #endif