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)
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
21 *------------------------------------------------------------------
24 #include "u_parameter.h"
25 #include "u_function.h"
28 /*--------------------------------------------------------------------------*/
29 /*--------------------------------------------------------------------------*/
31 /*--------------------------------------------------------------------------*/
32 class CMD_MEASURE
: public CMD
{
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());
42 trace1("CMD_MEASURE::do_it 1", f
->label());
43 WAVE_FUNCTION
* ff
= dynamic_cast<WAVE_FUNCTION
*>(f
);
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 )");
52 OMSTREAM out
= IO::mstdout
;
54 out
<< assign_to
<< '=' << value
<< '\n';
55 PARAM_LIST
* pl
= Scope
->params();
56 pl
->set(assign_to
, value
);
59 throw Exception_No_Match(function
);
63 DISPATCHER
<CMD
>::INSTALL
d0(&command_dispatcher
, "measure", &p0
);
64 /*--------------------------------------------------------------------------*/
66 /*--------------------------------------------------------------------------*/
67 /*--------------------------------------------------------------------------*/
68 // vim:ts=8:sw=2:noet: