Qucs-core
0.0.19
|
00001 /* 00002 * variable.h - generic variable class definitions 00003 * 00004 * Copyright (C) 2004, 2007 Stefan Jahn <stefan@lkcc.org> 00005 * 00006 * This is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2, or (at your option) 00009 * any later version. 00010 * 00011 * This software is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this package; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 * $Id$ 00022 * 00023 */ 00024 00025 #ifndef __VARIABLE_H__ 00026 #define __VARIABLE_H__ 00027 00028 #include <string> 00029 00030 #include "components/microstrip/substrate.h" 00031 #include "analysis.h" 00032 #include "equation.h" 00033 00034 00035 00036 //using namespace qucs::eqn; 00037 namespace qucs { 00038 00039 // Enumerate possible types of variables. 00040 enum variably_type { 00041 VAR_UNKNOWN = -1, // not yet defined 00042 VAR_CONSTANT, // equation constant 00043 VAR_REFERENCE, // equation reference 00044 VAR_SUBSTRATE, // substrate definition 00045 VAR_VALUE, // equation result 00046 VAR_ANALYSIS // analysis 00047 }; 00048 00049 class substrate; 00050 class analysis; 00051 00052 namespace eqn { 00053 class equation; 00054 class constant; 00055 } 00056 00057 00058 class variable 00059 { 00060 public: 00061 variable (); 00062 variable (const char * const n); 00063 variable (const variable &); 00064 virtual ~variable () = default; 00065 00067 void setName (const char * const n) { 00068 name = n ? std::string(n) : std::string(); 00069 }; 00070 00072 const char * getName (void) const { 00073 return this->name.c_str(); 00074 }; 00075 void setNext (variable * const v) { next = v; } 00076 variable * getNext (void) const { return next; } 00077 00078 void setType (const int t) { type = t; } 00079 int getType (void) const { return type; } 00080 00081 void setConstant (eqn::constant * const c) { type = VAR_CONSTANT; value.c = c; } 00082 eqn::constant * getConstant (void) const { return value.c; } 00083 void setReference (eqn::reference * const r) { type = VAR_REFERENCE; value.r = r; } 00084 eqn::reference * getReference (void) const { return value.r; } 00085 void setSubstrate (substrate * const s) { type = VAR_SUBSTRATE; value.s = s; } 00086 substrate * getSubstrate (void) { return value.s; } 00087 void setValue (eqn::constant * const v) { type = VAR_VALUE; value.v = v; } 00088 eqn::constant * getValue (void) { return value.v; } 00089 void setAnalysis (analysis * const a) { type = VAR_ANALYSIS; value.a = a; } 00090 analysis * getAnalysis (void) const { return this->value.a; } 00091 const char * toString (void); 00092 void setPassing (const bool p) { this->pass = p; } 00093 bool getPassing (void) const { return this->pass; } 00094 00095 private: 00096 std::string name; 00097 bool pass; 00098 int type; 00099 union value_t { 00100 eqn::constant * c; // equation constant 00101 eqn::reference * r; // equation reference 00102 substrate * s; // substrate definition 00103 eqn::constant * v; // equation result 00104 analysis * a; // analysis 00105 } value; 00106 variable * next; 00107 }; 00108 00109 } // namespace qucs 00110 00111 #endif /* __VARIABLE_H__ */