bump to -rc12
[gnucap-felix.git] / src / c_measure.cc
blob2b322d5090e5cd55d9f201ca65a2b749b34910c9
1 /*
2 * Copyright (C) 2008 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 *------------------------------------------------------------------
23 //testing=none
24 #include "u_parameter.h"
25 #include "u_function.h"
26 #include "c_comand.h"
27 #include "globals.h"
28 /*--------------------------------------------------------------------------*/
29 /*--------------------------------------------------------------------------*/
30 namespace {
31 /*--------------------------------------------------------------------------*/
32 class CMD_MEASURE : public CMD {
33 public:
34 void do_it(CS& Cmd, CARD_LIST* Scope)
36 trace1("CMD_MEASURE::do_it", (string(Cmd)));
37 std::string assign_to, function;
38 Cmd >> assign_to >> '=' >> function >> '(';
39 if (FUNCTION_BASE* f = measure_dispatcher[function]) {
40 trace1("CMD_MEASURE::do_it", f->label());
41 f->expand(Cmd,Scope);
42 trace1("CMD_MEASURE::do_it 1", f->label());
43 WAVE_FUNCTION* ff= dynamic_cast<WAVE_FUNCTION*>(f);
44 USE(ff);
46 trace3("CMD_MEASURE::do_it 2", f->label(), hp(ff), hp(f));
47 fun_t value = f->eval(Cmd, Scope); // FIXME?
48 if (!Cmd.skip1b(')')) {
49 Cmd.warn(bWARNING, "need )");
50 }else{
52 OMSTREAM out = IO::mstdout;
53 out.outset(Cmd);
54 out << assign_to << '=' << value << '\n';
55 PARAM_LIST* pl = Scope->params();
56 pl->set(assign_to, value);
57 out.outreset();
58 }else{
59 throw Exception_No_Match(function);
62 } p0;
63 DISPATCHER<CMD>::INSTALL d0(&command_dispatcher, "measure", &p0);
64 /*--------------------------------------------------------------------------*/
66 /*--------------------------------------------------------------------------*/
67 /*--------------------------------------------------------------------------*/
68 // vim:ts=8:sw=2:noet: