00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00031 #ifndef SIMTHETIC_PARAMETERDESCRIPTION_H
00032 #define SIMTHETIC_PARAMETERDESCRIPTION_H
00033
00034 #include <simthetic/propertylist.h>
00035 #include <simthetic/exceptions.h>
00036 #include <string>
00037 #include <map>
00038 #include <sstream>
00039
00040 namespace simth {
00041
00042 class GwenXmlWrapper;
00043
00046 class ParameterDescription
00047 {
00048 public:
00051 static std::string opener;
00054 static std::string closer;
00057 static char marker;
00058
00060 class Variables
00061 {
00062 typedef std::pair<std::string,std::string> pair_string;
00063 typedef std::map<std::string,std::string> map_type;
00064 typedef map_type::const_iterator map_const_iterator;
00065 typedef map_type::value_type map_value_type;
00066 typedef Property::StringPairList StringPairList;
00067 map_type _vars;
00068 bool _verbose;
00069 public:
00071 Variables() {};
00074 Variables(const GwenXmlWrapper& pnode, bool verbose);
00078 std::string parse(const std::string&) const;
00079 };
00081 class Propertyvalue
00082 {
00083 public:
00085 Propertyvalue() {};
00088 Propertyvalue(const GwenXmlWrapper& pnode, const Variables& vars);
00089 std::string name;
00090 std::string value;
00091 };
00094 class Devicevalues
00095 {
00096 private:
00097 std::string type_escaped;
00098 public:
00100 Devicevalues() {};
00103 Devicevalues(const GwenXmlWrapper& devnode, const Variables& vars);
00104 std::string id;
00105 std::string type;
00106 std::string description;
00107 std::vector<Propertyvalue> propertyvalues;
00108
00112 void fillProperties(PropertyList& properties) const;
00113 };
00115 class Loopvariable
00116 {
00117 public:
00119 Loopvariable() {};
00122 Loopvariable(const GwenXmlWrapper& lnode, const Variables& vars);
00123 std::string id;
00124 std::string name;
00125 std::string type;
00126 std::string description;
00127 Property::list_string values;
00128 };
00130 class Connection
00131 {
00132 public:
00134 Connection() {};
00137 Connection(const GwenXmlWrapper& cnode);
00138 std::string fromid, fromintf, toid, tointf;
00139 bool active;
00140 };
00141
00143 ParameterDescription() {};
00145 ParameterDescription(const std::string& filename,
00146 bool verbose);
00147
00149 ParameterDescription(const GwenXmlWrapper& simulationparameters,
00150 const std::string& filename,
00151 bool verbose);
00152
00154 static unsigned id_to_int(const std::string&);
00155
00157 std::string title;
00162 Devicevalues globalvalues;
00164 std::vector<Devicevalues> devicesvalues;
00166 std::vector<Loopvariable> loopvariables;
00168 std::vector<Connection> connectionlist;
00169
00171 std::string parseVars(const std::string& s) const
00172 { return vars.parse(s); }
00173
00174 private:
00176 void readFromXML(const GwenXmlWrapper& simulationparameters,
00177 const std::string& filename,
00178 bool verbose);
00179
00181 Variables vars;
00182
00183 public:
00184
00213 class Parser {
00214 enum Token_value {
00215 NUMBER, END,
00216 PLUS='+', MINUS='-', MUL='*', DIV='/',
00217 LP='(', RP=')'
00218 };
00219 Token_value curr_tok;
00220 double number_value;
00221 std::istringstream istr;
00222
00223
00224 double expr(bool);
00225
00226 double term(bool);
00227
00228 double prim(bool);
00229
00230 Token_value get_token();
00231 public:
00233 Parser(const std::string&);
00240 std::string run();
00241
00247 static std::string parse(const std::string&);
00248 };
00249
00250
00251 };
00252
00253 }
00254
00255
00256 #endif
00257
00258
00259