[sane-devel] GSOC idea - develope sane-generic backend
Robert Ancell
robert.ancell at canonical.com
Fri Mar 26 01:23:40 UTC 2010
Hi all,
One thing I've noticed developing simple-scan is a lot of the SANE
backends implement the same functionality. For example managing the
table of options. It would be nice if there was a generic sane driver
that the others could derive from, e.g.
static SANEGenericDriver *driver;
static void connect(SANEGenericDriver *driver)
{
// Do USB connection
}
static void start_page(SANEGenericDriver *driver)
{
// Do USB config
// using sgd_get_resolution(driver) etc
}
static void read(SANEGenericDriver *driver)
{
// Do USB read data
}
static void end_page(SANEGenericDriver *driver)
{
// Do USB config
}
static void disconnect(SANEGenericDriver *driver)
{
// Clean up USB connection
}
void init()
{
SANE_Int resultions[] = {75, 150, 300, 600};
driver = sgd_new ("plustek");
sgd_set_color_mode (driver, true);
sgd_set_supported_resolutions (driver, resolutions, 4);
sgd_add_custom_option_int (driver, "toggle");
sgd_set_connect (driver, connect);
sgd_set_start_page (driver, start_page);
sgd_set_read (driver, read);
sgd_set_end_page (driver, end_page);
sgd_set_disconnect (driver, disconnect);
}
SGD_SANE_INTERFACE(driver)
/* Generates:
void sane_init()
{
sgd_sane_init(driver);
}
etc...*/
Advantages of this approach:
- Less code duplication
- Easier driver development (driver doesn't have to maintain
configuration table etc)
- SANEGenericDriver always correctly implements SANE interface:
- Validates inputs
- Uses names defined in saneopts.h
- Can handle corner cases better, e.g. sane_cancel being called at
unexpected times
- Can change SANE interface easier
This seems like a good project for a summer of code student to perform,
would anyone be interested in being a mentor?
--Robert
More information about the sane-devel
mailing list