Le Thu, May 06, 2004, Ã 10:44:27AM +0200, Alexandre Fen-Chong a écrit:
> I'm sorry for my english, it isn't my mothertongue I'm French :)
so is mine.
> I give an example of what I want to do.
> For instance, with the object router in Network I would like to add a property
> "ip" with a field to fill in.
OK, sounds reasonable.
> In fact, I would add new properties to some objects and create new objects with
> properties in differents tabs (as in the object class of UML objects).
>
>
> In this case, taking the object class of UML as model is it correct ?
NO!
> Or there is an object recommanded to be used as model ?
plenty. Almost all of them.
> Do you have some pieces of advice in order to not do a object obsolete ?
Yes. Stay clear of "UML - Class". Most other objects are fine, but this
one is a sticking point.
If I understand correctly your requirements, you would like to:
i) add properties to existing objects (or to new objects similar
to existing objects)
switch (object type) {
case C_programmed_object:
no brainer, add a field to the object's struct, declare
the property into the object's StdProp arrays (the
Properties array, and the PropOffsets array); break;
case shape:
much, much more tricky at this point. There were many
grand proposals of sprinkling Magic Forbes XML Dust(tm)
to make those shapes way smarter, but so far
implementation is a bit lacking.
I think a possible way would be to write for the
specific shape you're interested in, a subclass of
"Custom - Generic", which provides those extra
properties and behaviour you want to add.
Or another possible way would be to first reimplement
the shape as a C object, making sure that diagrams
created when it was a shape still reload fine and are
visually close enough (you'd be amazed how painful the
.90->.91 transition could have been at some places), and
then start adding your extra properties.
Or, as a cop-out to the previous item, start writing a
new implementation that doesn't pretend to be an evolved
version of the shape (ie, it has another type name) and
just make the older shape disappear from the toolbox
when you're ready to transition (but then you have to
keep the shape around forever, or provide some
on-the-fly conversion facility we don't have for now);
break;
}
ii) create new property types
e.g: ipv4-validating fields (please check the Received:
header for this e-mail, especially as it moves from
machine "muscat" to machine "traminer" -- when
you write this property, please consider us
lowly ipv6 users)
a little more complicated than i)C), but by all means not unfeasible.
Please have a look at lib/prop*.[ch]
iii) organise properties in property pages
please grep for PROP_TYPE_NOTEBOOK_
I hope this helps.
-- Cyrille
--