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 typedef struct GWEN__XMLNODE GWEN_XMLNODE;
00041
00042 namespace simth {
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(GWEN_XMLNODE *pnode, bool verbose);
00078 std::string parse(const std::string&) const;
00079 };
00081 class Propertyvalue
00082 {
00083 public:
00085 Propertyvalue() {};
00088 Propertyvalue(GWEN_XMLNODE *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(GWEN_XMLNODE *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(GWEN_XMLNODE *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(GWEN_XMLNODE *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(GWEN_XMLNODE *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:
00177 static GWEN_XMLNODE *_getSimulationNode(const std::string& fname,
00178 GWEN_XMLNODE *rootnode)
00179 throw (file_not_found, bad_device_file);
00181 void readFromXML(GWEN_XMLNODE *simulationparameters,
00182 const std::string& filename,
00183 bool verbose);
00184
00186 Variables vars;
00187
00188 public:
00189
00218 class Parser {
00219 enum Token_value {
00220 NUMBER, END,
00221 PLUS='+', MINUS='-', MUL='*', DIV='/',
00222 LP='(', RP=')'
00223 };
00224 Token_value curr_tok;
00225 double number_value;
00226 std::istringstream istr;
00227
00228
00229 double expr(bool);
00230
00231 double term(bool);
00232
00233 double prim(bool);
00234
00235 Token_value get_token();
00236 public:
00238 Parser(const std::string&);
00245 std::string run();
00246
00252 static std::string parse(const std::string&);
00253 };
00254
00255
00256 };
00257
00258 }
00259
00260
00261 #endif
00262
00263
00264