[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnucap-devel] set_param_by_name for bm
From: |
Felix Salfelder |
Subject: |
[Gnucap-devel] set_param_by_name for bm |
Date: |
Sun, 29 Apr 2012 14:30:41 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Hi List.
first of all, congratulations to Savant!
i'm working on the once mentioned set_param_by_name patch, and if it's
useful for the gsoc plugin, i'll try to complete it soon.
i've figured out a way to avoid linear search (mostly for adms models, as
they have much more parameters), and i'd like to do the bm*-parameters
the same way. what it looks like is this:
- add a static std::map< > param_dict to the EVAL_BM_* classes
- add PARA_BASE, a base class for the PARAMETER<T> classes.
- have boost installed
- do some class-member-pointer mess
finally, for example bm_pulse.cc reads something like this:
/*--------------------------------------------------------------------------*/
map<string, PARA_BASE EVAL_BM_PULSE::*> EVAL_BM_PULSE::param_dict =
boost::assign::map_list_of
("iv", (PARA_BASE EVAL_BM_PULSE::*) &EVAL_BM_PULSE::_iv)
[..]
("period",(PARA_BASE EVAL_BM_PULSE::*) &EVAL_BM_PULSE::_period);
/*--------------------------------------------------------------------------*/
void EVAL_BM_PULSE::set_param_by_name(string Name, string Value)
{
if( PARA_BASE EVAL_BM_PULSE::* x = (param_dict[Name]) ) {
PARA_BASE* p = &(this->*x);
*p = Value;
} else {
throw Exception_No_Match(Name);
}
}
/*--------------------------------------------------------------------------*/
so, PARA_BASE EVAL_BM_PULSE::* is somewhat the C++ type specifying an
offset to a member in a struct. these should imho be stored in a stack
allocated map.
do you agree, that this is better than linear search? any clues on how
to avoid the extra casts in the map initialization?
regards
felix
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnucap-devel] set_param_by_name for bm,
Felix Salfelder <=