[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gEDA-dev: New diagram (attempt at UML)
I think I like the union inside the object especially for complex
objects which has a list of
GList *prim_objs; // Other Primitive objects
else it would have to have lists for arcs, boxes, circles, lines, text
and pictures.
struct st_complex {
char *basename;
BOOL is_hierarchy_io; // is this an interpage hierarchical symbol?
BOOL is_schematic_sym; // is this a symbol that has a schematic?
DISPLAY *display; // how object relates to world and display window
BOOL embeded;
GList *net_pin_objs; // list of net pins
GList *bus_pin_objs; // list of bus pins
GList *hidden_nets; // list of nets
GList *prim_objs; // Other Primitive objects
};
On Thu, 2007-03-22 at 10:01 +0000, Peter Clifton wrote:
> 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,
>
_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev