1 /*$Id: u_probe.h,v 1.6 2010-09-22 13:19:51 felix Exp $ -*- C++ -*-
3 * Copyright (C) 2001 Albert Davis
4 * Author: Albert Davis <aldavis@gnu.org>
6 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3, or (at your option)
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 *------------------------------------------------------------------
25 //testing=script,complete 2006.07.14
29 #include "l_compar.h" // inorder
30 #include "e_cardlist.h" // inorder
31 #include "m_expression.h"
32 #include "u_function.h"
33 /*--------------------------------------------------------------------------*/
35 /*--------------------------------------------------------------------------*/
36 #define MATH_OP_CONST 0
37 #define MATH_OP_UNARY 1 * 32
38 #define MATH_OP_BINARY 2 * 32
39 #define MATH_OP_OTHER 3 * 32
40 #define MATH_OP_SET 4 * 32
42 #define MATH_OP_MASK 7 * 32
45 // this is c-ish. fixme
46 // use parameter expressions and a list of probes instead.
48 op_null
= MATH_OP_CONST
, // constant value.
50 op_sum
= MATH_OP_SET
, // argument is a set
52 op_exp
= MATH_OP_UNARY
,
61 op_diff
= MATH_OP_BINARY
,
65 MATH_OP
strtotype( std::string
);
66 char typetochar(MATH_OP
);
68 inline bool is_const(MATH_OP x
){
72 inline bool is_unary(MATH_OP x
){
73 return x
>=MATH_OP_UNARY
&& x
<MATH_OP_BINARY
;
76 /*--------------------------------------------------------------------------*/
77 /*--------------------------------------------------------------------------*/
78 class INTERFACE PROBE
: public CKT_BASE
{
81 std::string _override_label
;
83 explicit PROBE(): _brh(0),_next(0) {unreachable(); incomplete();}
84 explicit PROBE(const std::string
& what
, const CKT_BASE
*brh
);
85 PROBE(const PROBE
& p
);
88 virtual double value()const;
90 void set_override_label(const std::string _override
) { _override_label
=_override
; } // ???
92 PROBE
* arg() const {return _arg
;}
93 std::string
override_label() const {return _override_label
;}
94 virtual PROBE
* clone()const { return (new PROBE(*this));}
95 virtual void expand(){}
96 virtual void precalc_last(){}
103 void set_limit(double Lo
,double Hi
) {_lo
= Lo
; _hi
= Hi
;}
104 void set_next( PROBE
* n
) { assert(this); _next
=n
;}
106 PROBE
& operator=(const PROBE
& p
);
108 virtual const std::string
label()const;
109 const CKT_BASE
* object()const {return _brh
;}
110 double lo()const {return _lo
;}
111 double hi()const {return _hi
;}
112 double range()const {return hi()-lo();}
113 bool in_range()const{return in_order(lo(),value(),hi());}
114 PROBE
* next()const {return _next
;}
116 double probe_node()const;
119 PROBE
* _arg
; // ->MATH_PROBE
121 public: // compare probes.
122 bool operator==(const PROBE
& p
)const
123 { return ( ( _what
== p
._what
)
124 // &&( _override_label == p._override_label ) ???
125 &&( _brh
== p
._brh
));
129 public: // compare (for STL)
130 bool operator==(const CKT_BASE
& brh
)const;
131 bool operator!=(const CKT_BASE
& brh
)const
132 { untested(); return (object() != &brh
); }
133 bool operator==(const std::string
& par
)const
134 { return wmatch(label(), par
); }
135 bool operator!=(const std::string
& par
)const
136 { untested(); return !( *this == par
); }
140 /*--------------------------------------------------------------------------*/
141 class MATH_PROBE
: public PROBE
{
143 MATH_PROBE(): PROBE() {_next
=0;untested(); _arg
=0;};
144 MATH_PROBE(const MATH_OP type
) { _type
=type
; _next
=NULL
; _arg
=0; }
145 MATH_PROBE(const MATH_PROBE
& p
);
146 virtual PROBE
* clone()const { return new MATH_PROBE(*this);}
147 MATH_OP
type()const{return(_type
);}
148 MATH_PROBE
& operator=(const MATH_PROBE
& p
);
149 void set_arg( PROBE
* );// { assert(this); _arg=n;}
156 const std::string
label()const;
159 /*--------------------------------------------------------------------------*/
160 class EVAL_PROBE
: public PROBE
{
162 EVAL_PROBE(): PROBE() {_cmd
="none";untested();};
163 EVAL_PROBE(const EVAL_PROBE
& p
);
164 explicit EVAL_PROBE(const std::string
& what
, const CARD_LIST
* scope
);
165 virtual PROBE
* clone()const { return new EVAL_PROBE(*this);}
166 EVAL_PROBE
& operator=(const EVAL_PROBE
& p
);
168 // FIXME carry expression. not _cmd and _scope
171 const CARD_LIST
* _scope
;
174 const std::string
label()const { return _cmd
; }
176 /*--------------------------------------------------------------------------*/
177 class MEAS_PROBE
: public PROBE
{
179 MEAS_PROBE(): PROBE() {_cmd
="none";untested();};
180 MEAS_PROBE(const MEAS_PROBE
& p
);
181 explicit MEAS_PROBE(const std::string
& what
);
182 explicit MEAS_PROBE(const std::string
& what
, const CARD_LIST
* scope
);
183 virtual PROBE
* clone()const { return new MEAS_PROBE(*this);}
184 MEAS_PROBE
& operator=(const MEAS_PROBE
& p
);
187 const CARD_LIST
* _scope
;
192 void precalc_first();
195 const std::string
label()const;
198 /*--------------------------------------------------------------------------*/