testing
[gnucap-felix.git] / src / bm_generator.cc
blobf6f6dbce640b82679778aaf103c32f747c4d1511
1 /*$Id: bm_generator.cc 2015.01.08 al $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
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.
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.
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 * behavioral modeling simple value
23 * used with tc, etc, and conditionals
25 //testing=script,complete 2005.10.06
26 #include "globals.h"
27 #include "e_elemnt.h"
28 #include "bm.h"
29 /*--------------------------------------------------------------------------*/
30 namespace {
31 /*--------------------------------------------------------------------------*/
32 class EVAL_BM_GENERATOR : public EVAL_BM_ACTION_BASE {
33 private:
34 explicit EVAL_BM_GENERATOR(const EVAL_BM_GENERATOR& p);
35 public:
36 explicit EVAL_BM_GENERATOR(int c=0);
37 ~EVAL_BM_GENERATOR() {
38 trace0("~EVAL_BM_GENERATOR");
40 private: // override virtual
41 bool operator==(const COMMON_COMPONENT&)const;
42 COMMON_COMPONENT* clone()const {return new EVAL_BM_GENERATOR(*this);}
43 void print_common_obsolete_callback(OMSTREAM&, LANGUAGE*)const;
44 void tr_eval(ELEMENT*)const;
45 void ac_eval(ELEMENT*)const;
46 std::string name()const {return "generator";}
47 bool ac_too()const {return true;}
48 bool parse_numlist(CS&);
50 /*--------------------------------------------------------------------------*/
51 /*--------------------------------------------------------------------------*/
52 EVAL_BM_GENERATOR::EVAL_BM_GENERATOR(int c)
53 :EVAL_BM_ACTION_BASE(c)
56 /*--------------------------------------------------------------------------*/
57 EVAL_BM_GENERATOR::EVAL_BM_GENERATOR(const EVAL_BM_GENERATOR& p)
58 :EVAL_BM_ACTION_BASE(p)
61 /*--------------------------------------------------------------------------*/
62 bool EVAL_BM_GENERATOR::operator==(const COMMON_COMPONENT& x)const
64 const EVAL_BM_GENERATOR* p = dynamic_cast<const EVAL_BM_GENERATOR*>(&x);
65 if (p) {
66 }else{untested();
68 bool rv = p && EVAL_BM_ACTION_BASE::operator==(x);
69 if (rv) {untested();
70 }else{
72 return rv;
74 /*--------------------------------------------------------------------------*/
75 void EVAL_BM_GENERATOR::print_common_obsolete_callback(OMSTREAM& o, LANGUAGE* lang)const
77 assert(lang);
78 o << name();
79 EVAL_BM_ACTION_BASE::print_common_obsolete_callback(o, lang);
81 /*--------------------------------------------------------------------------*/
82 void EVAL_BM_GENERATOR::tr_eval(ELEMENT* d)const
84 tr_finish_tdv(d, d->_sim->_genout);
86 /*--------------------------------------------------------------------------*/
87 void EVAL_BM_GENERATOR::ac_eval(ELEMENT* d)const
89 d->_ev = 1;
90 ac_final_adjust_with_temp(&(d->_ev));
92 /*--------------------------------------------------------------------------*/
93 bool EVAL_BM_GENERATOR::parse_numlist(CS& cmd)
95 unsigned here = cmd.cursor();
96 PARAMETER<double> new_value(NOT_VALID);
97 cmd >> new_value;
98 if (cmd.gotit(here)) {
99 _scale = new_value;
100 return true;
101 }else{
102 return false;
105 /*--------------------------------------------------------------------------*/
106 /*--------------------------------------------------------------------------*/
107 EVAL_BM_GENERATOR p1(CC_STATIC);
108 DISPATCHER<COMMON_COMPONENT>::INSTALL d1(&bm_dispatcher, "gen|generator", &p1);
110 /*--------------------------------------------------------------------------*/
111 /*--------------------------------------------------------------------------*/
112 // vim:ts=8:sw=2:noet: