Additional info on new solver parameter routines. This routine attempts to make declaration of new parameters possible with simple syntax, without requiring changes to the underlying data structure. Also aim to eliminate the extensive defines used in the old approach, and eliminate the risk of messing up the parameter list by forgetting to update something.

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

Note:
There is a new syntax available for setting solver parameters that has not yet been documented here. See slv_common.h (~line 280) and also solver/ida.c for examples.
When used together the parameter-related structures, functions, and macros allow us to define all of a solver's parameters in one file and notify the interface of these parameters upon startup (dynamic interface construction). The parameters can be defined in any order. The only bookkeeping needed is associated with the macros. You must have an array of void pointers large enough for all of the macros you define and you must give each of the macros you define a unique element of this array. Here is an example using a real parameter and a character parameter. (The int and bool are similar to the real).

    (* 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]);

Generated on Thu Jul 17 04:00:54 2008 for libascend by  doxygen 1.5.1