Qucs-core  0.0.19
environment.h
Go to the documentation of this file.
00001 /*
00002  * environment.h - variable environment class definitions
00003  *
00004  * Copyright (C) 2004, 2006, 2007, 2009 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 
00031 #ifndef __ENVIRONMENT_H__
00032 #define __ENVIRONMENT_H__
00033 
00034 #include <list>
00035 #include <string>
00036 
00037 #include "equation.h"
00038 
00039 namespace qucs {
00040 
00041 class variable;
00042 class checker;
00043 class solver;
00044 class dataset;
00045 
00046 
00054 class environment
00055 {
00056  public:
00057   environment ();
00058   environment (const std::string & p_name);
00059   environment (const environment &);
00060   virtual ~environment ();
00061   void copy (const environment &);
00062   void setName (char *) = delete;
00063   void print (const bool all = false) const;
00064   void setDefinitions (struct definition_t * const d) { defs = d; }
00065   struct definition_t * getDefinitions (void) const { return defs; }
00066 
00067   // variable specific functionality
00068   void copyVariables (variable *);
00069   void deleteVariables (void);
00070   void addVariable (variable * const, const bool pass = true);
00071   variable * getVariable (const char * const) const;
00072 
00073   // equation specific functionality
00074   void setChecker (eqn::checker * c) { checkee = c; }
00075   eqn::checker * getChecker (void) { return checkee; }
00076   void setSolver (eqn::solver * s) { solvee = s; }
00077   eqn::solver * getSolver (void) { return solvee; }
00078   int equationChecker (const int noundefined = 1) const;
00079   int equationSolver (dataset * const);
00080   int runSolver (void);
00081   void equationSolver (void);
00082 
00083   // subcircuit specific
00084   qucs::vector getVector (const char * const) const ;
00085   void setDoubleConstant (const char * const, const nr_double_t);
00086   nr_double_t getDoubleConstant (const char * const) const;
00087   void setDouble (const char * const , nr_double_t);
00088   nr_double_t getDouble (const char * const) const;
00089   void setDoubleReference (const char * const, char *);
00090   char * getDoubleReference (const char * const) const;
00091   void updateReferences (environment *);
00092   void passConstants (void);
00093   void fetchConstants (void);
00094   variable * findValue (char *);
00095   void setValue (char *, eqn::constant *);
00096   void saveResults (void);
00097 
00099   inline void push_front_Child (environment * child) {
00100     children.push_front (child);
00101   }
00102 
00104   void remove_Child (environment * child) {
00105     children.remove (child);
00106   }
00107 
00109   void setName (const std::string &p_name) {
00110     this->name = p_name;
00111   }
00112 
00114   const std::string & getName(void) const {
00115     return this->name;
00116   }
00117 
00118  private:
00119   std::string name;
00120   variable * root;
00121   eqn::checker * checkee;
00122   eqn::solver * solvee;
00123   std::list<environment *> children;
00124   bool iscopy;
00125   struct definition_t * defs;
00126 };
00127 
00128 } // namespace qucs
00129 
00130 #endif /* __ENVIRONMENT_H__ */