On Wed, 15 Aug 2001, Kevin Lawton wrote:
> > I have put a lot of time and coding into a get/set parameter interface for
> > Bochs, in the context of moving toward a graphical configuration
> > interface. In the current Bochs CVS version, each parameter is associated
> > with a small data structure which encodes its type, short name, long
> > description, and for integers the min and max allowed values. With this
> > strategy, you have to code the parsing, user interaction, loading/saving,
> > range checking, etc. once per data type instead of once per parameter.
> > The code is in gui/siminterface.h and gui/siminterface.cc in the bochs CVS
> > tree. Yes, it's written as C++ objects and I know that's an issue.
>
>
> I noticed work had been done in bochs to the bx_options processing.
> I definitely want to delete that structure as it is now, and make
> things more modular. I'll have a closer look at what you have coded
> in bochs for options parsing. As one of the goals of mine is to
> merge with the bochs device models, it will be good if I can find
> a mechanism which is not far from what you have. More after I
> have a better look...
I haven't changed the parsing of the bochsrc at all, even though it really
needs to be done. What has changed is that the values are stored in
parameter structures instead of plain ints and char[]s. For example in
bochs.h:
typedef struct {
bx_param_string_c *Opath;
bx_param_bool_c *OcmosImage;
bx_param_num_c *Otime0;
} bx_cmos_options;
The path gets initialized as follows, in main.cc
bx_options.cmos.Opath = new bx_param_string_c (BXP_CMOS_PATH,
"cmos-image",
"Pathname of CMOS image file",
"", // initial value
BX_PATHNAME_LEN);
Then to get the path, it's
bx_options.cmos.Opath->getptr ();
To change the path,
bx_options.cmos.Opath->set (strdup(params[1]));
And to prompt the user for a new value for the path and set it, in
gui/control.cc:
ptr->text_ask (stdin, stderr);
(ptr could point to any parameter of any type, since text_ask is virtual)
For parameters with more complex behavior, you can also set up a "handler"
(callback function) that is called whenever the value changes. There are
several examples of this in main.cc (bx_param_handler).
-Bryce