QSapecNG
 All Classes Functions Enumerations Properties
parser.h
00001 /*
00002     SapecNG - Next Generation Symbolic Analysis Program for Electric Circuit
00003     Copyright (C) 2009, Michele Caini
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef PARSER_H
00021 #define PARSER_H
00022 
00023 
00024 #include <string>
00025 #include <vector>
00026 #include <map>
00027 
00028 
00029 namespace sapecng
00030 {
00031 
00032 
00033 class abstract_builder
00034 {
00035 
00036 public:
00037   enum const_vertex
00038     { GROUND = 0, };
00039 
00040   enum dual_component_type
00041     {
00042       R,  // Resistor component type
00043       G,  // Admittance component type
00044       L,  // Inductor component type
00045       C,  // Capacitor component type
00046       V,  // Voltage source component type
00047       I,  // Current source component type
00048       VM,  // Voltmeter component type
00049       AM,  // Ammeter component type
00050     };
00051 
00052   enum quad_component_type
00053     {
00054       VCCS,  // Voltage controlled current source component type
00055       VCVS,  // Voltage controlled voltage source component type
00056       CCCS,  // Current controlled current source component type
00057       CCVS,  // Current controlled voltage source component type
00058       AO,  // Operational amplifier component type
00059       n,  // Ideal transformer component type
00060       K,  // Mutual inductance component type
00061     };
00062 
00063   enum userdef_component_type
00064     {
00065       X,  // User defined component type
00066     };
00067 
00068 public:
00069   virtual ~abstract_builder() { }
00070 
00071   virtual void add_circuit_properties(
00072     std::map<std::string,std::string> map) = 0;
00073   virtual void add_circuit_property(
00074     std::string name, std::string value) = 0;
00075 
00076   virtual void add_wire_component(
00077       std::map<std::string,std::string> props =
00078         std::map<std::string,std::string>()
00079     ) = 0;
00080 
00081   virtual void add_out_component(
00082       unsigned int v,
00083       std::map<std::string,std::string> props =
00084         std::map<std::string,std::string>()
00085     ) = 0;
00086 
00087   virtual void add_dual_component(
00088       dual_component_type c_type,
00089       std::string name,
00090       double value,
00091       bool symbolic,
00092       unsigned int va,
00093       unsigned int vb,
00094       std::map<std::string,std::string> props =
00095         std::map<std::string,std::string>()
00096     ) = 0;
00097 
00098   virtual void add_quad_component(
00099       quad_component_type c_type,
00100       std::string name,
00101       double value,
00102       bool symbolic,
00103       unsigned int va,
00104       unsigned int vb,
00105       unsigned int vac,
00106       unsigned int vbc,
00107       std::map<std::string,std::string> props =
00108         std::map<std::string,std::string>()
00109     ) = 0;
00110 
00111   virtual void add_unknow_component(
00112       std::map<std::string,std::string> props =
00113         std::map<std::string,std::string>()
00114     ) = 0;
00115 
00116   virtual void begin_userdef_component(
00117       std::string name,
00118       std::map<std::string,std::string> props =
00119         std::map<std::string,std::string>()
00120     ) = 0;
00121 
00122   virtual void end_userdef_component(
00123       std::string name,
00124       std::map<std::string,std::string> props =
00125         std::map<std::string,std::string>()
00126     ) = 0;
00127 
00128   virtual void flush() = 0;
00129 
00130 };
00131 
00132 
00133 
00134 class abstract_parser
00135 {
00136 
00137 public:
00138   abstract_parser() { }
00139   virtual ~abstract_parser() { }
00140 
00141   virtual void parse(abstract_builder& builder) = 0;
00142 
00143 };
00144 
00145 
00146 
00147 }
00148 
00149 
00150 #endif // PARSER_H
 All Classes Functions Enumerations Properties