gEDA-dev: SELECTION, component library search order and more

Peter TB Brett peter at peter-b.co.uk
Mon Jan 15 03:09:35 EST 2007


On Friday 12 January 2007 17:09, Patrick Bernaud wrote:
> Hi all,
>
> I have been working on the selection in gschem to reintroduce the
> SELECTION type (as an alias of GList*) as it has been discussed on the
> list. I have also cleaned up the selection API quite a bit in libgeda
> and gschem and cleaned up the selection hooks in gschem.

Hi Patrick,

I haven't had time to look at your patches I'm afraid, but I do have a couple 
of comments about the way I think selections ought to work.  I'm *very* keen 
on moving all selection-manipulation code into libgeda, because it's not good 
API practise to have user code aware of the internals of your data 
structures.  In particular, I'd like to add:

 * accessor functions, so user code doesn't need to know how the selection is
   implemented.  This would be useful if we suddenly decided to switch to
   singly-linked lists, but might require the introduction of an iterator
   type.  Most of the stuff needed is there already, so all that's needed are
   get_iter() and next() functions, although making the remove() accessor
   accept an iterator as argument might lead to some speedup for large
   selection lists.

 * callbacks in libgeda.  With the accessor functions, that makes it possible
   to ensure that callbacks are executed *every* time the selection changes.
   During the summer I was trying to implement a sidebar that changed its
   contents depending on what was selected, and it was pretty much impossible
   to do with the then-current system.  The Guile callback system currently
   used in gschem could easily be adapted as a special case of the proposed
   system.

To do the latter, I'd like to see the initial implementation to be something 
like:

  typedef struct
  {
    GList *list;      // List of selected objects
    /* GList *callbacks; */
  } Selection;

  typedef struct
  {
    GList *current;   // Current list member
    int n;            // Index in list of current member
    Selection head;   // Selection list this iterator is for
  } SelectionIter;

Where what's inside the structs should NEVER be touched by anything outside 
libgeda...

Hope some of that seems sensible,

Peter


-- 
Fisher Society committee                    http://tinyurl.com/o39w2
CUSBC novices, match and league secretary   http://tinyurl.com/mwrc9
CU Spaceflight                              http://tinyurl.com/ognu2

v3sw6YChw7$ln3pr6$ck3ma8u7+Lw3+2m0l7Ci6e4+8t4Gb8en6g6Pa2Xs5Mr4p4
  hackerkey.com                                  peter-b.co.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.seul.org/pipermail/geda-dev/attachments/20070115/43b713ce/attachment.pgp


More information about the geda-dev mailing list