[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gEDA-dev: New diagram (attempt at UML)



On Wed, 2007-03-21 at 20:20 -0800, Steve Meier wrote:
> This is a non-object oriented version, c straight no ice.
> 
> struct st_object {
>   char obj_type;  // defined in o_types.h
> 
>   int reference_count;
> 
>   union {
>     ARC           *arc;
>     BOX           *box;
>     BUSRIPPER     *busripper;
>     CIRCLE        *circle;
>     COMPLEX       *complex;
>     CONN          *connector;
>     GEDA_VERSION  *version;
>     LINE          *line;
>     PLACEHOLDER   *placeholder;
>     PICTURE       *picture;
>     PIN           *pin;
>     SEGMENT       *segment;
>     TEXT          *text;
>   } data;
> 
> 
>   BOOL selected;            // object selected flag
>   BOOL visible;
>   BOOL locked;
>  
>   BOOL hierarchy_is_disabled;
> 
>   // attributes from symbol files
>   GList *sym_attribs;
> 
>   // attributes from schematic files
>   GList *sch_attribs;
> };

I'd probably not embed the objects as a union - although I'm not sure.
It is certainly better than the current way which has one of every
structure just in case.

I'd imagine going the gobject way, and start the "subclass" structure
with the parent's structure. C guarantees that this first element is
first in the struct's allocated memory, so you can type-cast say an ARC
object into the generic object. (OBJECT*)my_arc->object_property.

gobject also does some other things, like maintaining fields in the
gobject structure which it can verify your casting at run-time, and has
similarly inherited class structures for methods (it is fully object
oriented).

gobject isn't favoured for libgeda, but this way of inheriting
structures could be used (carefully).

Regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)



_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev