1 /*$Id: e_base.h,v 26.138 2013/04/24 02:32:27 al Exp $ -*- C++ -*-
2  * Copyright (C) 2001 Albert Davis
3  * Author: Albert Davis <aldavis@gnu.org>
4  *
5  * This file is part of "Gnucap", the Gnu Circuit Analysis Package
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301, USA.
21  *------------------------------------------------------------------
22  * real base for anything to do with a circuit
23  */
24 //testing=obsolete
25 #ifndef E_BASE_H
26 #define E_BASE_H
27 #include "md.h"
28 /*--------------------------------------------------------------------------*/
29 // external
30 class XPROBE;
31 class WAVE;
32 class OMSTREAM;
33 class SIM_DATA;
34 class PROBE_LISTS;
35 /*--------------------------------------------------------------------------*/
36 class INTERFACE CKT_BASE {
37 private:
38   mutable int	_probes;		/* number of probes set */
39   std::string	_label;
40 public:
41   static SIM_DATA* _sim;
42   static PROBE_LISTS* _probe_lists;
43   //--------------------------------------------------------------------
44 protected: // create and destroy
CKT_BASE()45   explicit CKT_BASE()			  :_probes(0), _label() {}
CKT_BASE(const std::string & s)46   explicit CKT_BASE(const std::string& s) :_probes(0), _label(s) {}
CKT_BASE(const CKT_BASE & p)47   explicit CKT_BASE(const CKT_BASE& p)	  :_probes(0), _label(p._label) {}
48   virtual  ~CKT_BASE();
49   //--------------------------------------------------------------------
50 public: // user stuff
help(CS &,OMSTREAM &)51   virtual void	      help(CS&, OMSTREAM&)const {untested();}
status()52   virtual std::string status()const {return "";}
53   //--------------------------------------------------------------------
54 public: // probes
55 	  double      probe_num(const std::string&)const;
56 	  double      ac_probe_num(const std::string&)const;
57   virtual double      tr_probe_num(const std::string&)const;
58   virtual XPROBE      ac_probe_ext(const std::string&)const;
inc_probes()59 	  void	      inc_probes()const	{++_probes;}
dec_probes()60 	  void	      dec_probes()const	{assert(_probes>0); --_probes;}
has_probes()61 	  bool	      has_probes()const	{return _probes > 0;}
62   static  double      probe(const CKT_BASE*,const std::string&);
63   static  WAVE*	      find_wave(const std::string& probe_name);
64   //--------------------------------------------------------------------
65 public: // label
66   bool operator!=(const std::string& n)const {return strcasecmp(_label.c_str(),n.c_str())!=0;}
67   virtual const std::string long_label()const;
short_label()68   const std::string&  short_label()const {return _label;}
set_label(const std::string & s)69   void	set_label(const std::string& s) {_label = s;}
70 };
71 /*--------------------------------------------------------------------------*/
exists(const CKT_BASE * c)72 inline bool exists(const CKT_BASE* c) {return c!=0;}
73 /*--------------------------------------------------------------------------*/
74 /*--------------------------------------------------------------------------*/
75 #endif
76