Usage: 1. declare IDs for the parameters you'll be using via an 'enum' (last ID is XXXX_PARAMS_COUNT) 2. allocate space for your slv_parameters_t::parms of size XXXX_PARAMS_COUNT 3. for each parameter, call slv_param_* as follows:
slv_param_int(p,XXXX_PARAM_NAME,(SlvParameterInitInt){ {"codename","guiname",3 (==guipagenum) "description"} ,1 (==default value) ,0 (==min), 100 (==max) });
4. to access a value from your code, use SLV_PARAM_BOOL(p,XXX_PARAM_NAME) etc (as defined in slv_common.h)
See example stuff in ida.c
(* these 4 macros can be defined anywhere more or less so long as it is before the calls to slv_define_parm. *) #define REAL_PTR (sys->parm_array[0]) #define REAL ((*(real64 *)REAL_PTR)) #define CHAR_PTR (sys->parm_array[1]) #define CHAR ((*(char **)CHAR_PTR)) #define PA_SIZE 2 struct example { struct slv_parameters_t p; void *parm_array[PA_SIZE]; struct slv_parameter padata[PA_SIZE]; } e; ... e.p.parms = padata; e.p.dynamic_parms = 0; static char *character_names[] = { "name_one","name_two" } (* fill padata with appropriate info *) slv_define_parm(&(e.p), real_parm, "r_parm","real parameter" , "this is an example of a real parameter" , U_p_real(val,25),U_p_real(lo,0),U_p_real(hi,100),1); (* now assign the element of e.parm_array from somewhere in padata *) SLV_RPARM_MACRO(REAL_PTR,parameters); (* fill padata with appropriate info *) slv_define_parm(&(e.p), char_parm, "c_parm", "character parameter", "this is an example of a character parameter", U_p_string(val,character_names[0]), U_p_strings(lo,character_names), U_p_int(hi,sizeof(character_names)/sizeof(char *)),1); (* now assign the element of e.parm_array that matches. *) SLV_CPARM_MACRO(CHAR_PTR,parameters); Resetting the value of a parameter can be done directly except for string parameters which should be set with, for example, slv_set_char_parameter(CHAR_PTR,newvalue); or outside a solver where there is no sys->parm_array: slv_set_char_parameter(&(p.parms[i].info.c.value),argv[j]);
1.5.1