Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

parameterdescription.h

Go to the documentation of this file.
00001 /*-*-c++-*-*****************************************************************
00002  parameterdescription.h
00003  ---------------
00004  begin       : March 2004
00005  copyright   : (C) 2004 by Christian Stimming
00006  email       : stimming@tuhh.de
00007 
00008  ***************************************************************************
00009  *                                                                         *
00010  *   This library is free software; you can redistribute it and/or         *
00011  *   modify it under the terms of the GNU Lesser General Public            *
00012  *   License as published by the Free Software Foundation; either          *
00013  *   version 2.1 of the License, or (at your option) any later version.    *
00014  *                                                                         *
00015  *   This library is distributed in the hope that it will be useful,       *
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00018  *   Lesser General Public License for more details.                       *
00019  *                                                                         *
00020  *   You should have received a copy of the GNU Lesser General Public      *
00021  *   License along with this library; if not, write to the Free Software   *
00022  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00023  *   MA  02111-1307  USA                                                   *
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      // expressions
00224      double expr(bool);
00225      // terms
00226      double term(bool);
00227      // primaries
00228      double prim(bool);
00229      // input function
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 } /* namespace */
00254 
00255 
00256 #endif /* SIMTHETIC_PARAMETERDESCRIPTION_H */
00257 
00258 
00259 

Generated on Mon Apr 24 21:19:19 2006 for simthetic by  doxygen 1.4.1