My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
variable.h
Go to the documentation of this file.
1 /*
2  * variable.h - generic variable class definitions
3  *
4  * Copyright (C) 2004, 2007 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id: variable.h 1825 2011-03-11 20:42:14Z ela $
22  *
23  */
24 
25 #ifndef __VARIABLE_H__
26 #define __VARIABLE_H__
27 
29 #include "analysis.h"
30 #include "equation.h"
31 
32 using namespace eqn;
33 
34 // Enumerate possible types of variables.
36  VAR_UNKNOWN = -1, // not yet defined
37  VAR_CONSTANT, // equation constant
38  VAR_REFERENCE, // equation reference
39  VAR_SUBSTRATE, // substrate definition
40  VAR_VALUE, // equation result
41  VAR_ANALYSIS // analysis
42 };
43 
44 class substrate;
45 class equation;
46 class analysis;
47 
48 class variable
49 {
50  public:
51  variable ();
52  variable (char *);
53  variable (const variable &);
54  virtual ~variable ();
55  void setName (char *);
56  char * getName (void);
57  void setNext (variable * v) { next = v; }
58  variable * getNext (void) { return next; }
59 
60  void setType (int t) { type = t; }
61  int getType (void) { return type; }
62  void setConstant (constant * c) { type = VAR_CONSTANT; value.c = c; }
63  constant * getConstant (void) { return value.c; }
64  void setReference (reference * r) { type = VAR_REFERENCE; value.r = r; }
65  reference * getReference (void) { return value.r; }
66  void setSubstrate (substrate * s) { type = VAR_SUBSTRATE; value.s = s; }
67  substrate * getSubstrate (void) { return value.s; }
68  void setValue (constant * v) { type = VAR_VALUE; value.v = v; }
69  constant * getValue (void) { return value.v; }
70  void setAnalysis (analysis * a) { type = VAR_ANALYSIS; value.a = a; }
71  analysis * getAnalysis (void) { return value.a; }
72  char * toString (void);
73  void setPassing (bool p) { pass = p; }
74  bool getPassing (void) { return pass; }
75 
76  private:
77  char * name;
78  char * text;
79  bool pass;
80  int type;
81  union value_t {
82  constant * c; // equation constant
83  reference * r; // equation reference
84  substrate * s; // substrate definition
85  constant * v; // equation result
86  analysis * a; // analysis
87  } value;
88  variable * next;
89 };
90 
91 #endif /* __VARIABLE_H__ */