[mfernan cnba uba ar: Dia - UML operations auto-generation]
- From: Fredrik Hallenberg <hallon lysator liu se>
- To: dia-list gnome org
- Subject: [mfernan cnba uba ar: Dia - UML operations auto-generation]
- Date: Tue, 12 Mar 2002 20:28:18 +0100
----- Forwarded message from Martin Fernandez <mfernan cnba uba ar> -----
From: Martin Fernandez <mfernan cnba uba ar>
Subject: Dia - UML operations auto-generation
To: hallon lysator liu se
Reply-to: mfernan cnba uba ar
X-Spam-Status: No, hits=0.0 required=5.0 tests= version=2.11
Hello,
I've downloaded Dia and it's really great. Thank you very much for writing
it. Beats the hell out of that ugly product named Visio. There's one small
nifty feature I wanted to implent. I tried to do it, but can't quite manage
to achieve it. I want to be able to generate two standard operations from
attributes, both 'set' and 'get' routines. That is, having an attribute named
'attr1' of type 't1', I want to generate an operation named 'get_attr1' of
type 't1' with no parameters, and its counterpart, an operation named
'set_attr1' of type void, with only one parameter of type 't1', and so on for
each attribute.
I can easily generate the operations using the attributes list of umlclass
but I can't manage to add them to the class. They always get somehow deleted.
If you could tell me which the correct procedure to add operations to a class
is, I would much appreciate it. I'm taking the liberty to include the
offending code:
(operation creation routines skipped)
(This routine is a callback of a button which I added to the Properties
Dialog)
static void
operations_getset_callback(GtkWidget *button, UMLClass *umlclass)
{
GList *atributos;
UMLAttribute *at;
UMLOperation *op;
GList *list;
GtkWidget *list_item;
char *str;
/* We must go through the attributes list */
atributos = umlclass->attributes;
list = NULL;
while (atributos != NULL)
{
/* Get attribute from attribute list */
at = (UMLAttribute *) atributos->data;
/* Create 'get' operation */
op = operations_generate_get_operation (at);
if (op == NULL)
printf ("\noperations_getset_callback - 'get' operation could not be
created.");
else
/* Add operation to our local operation list */
list = g_list_append(list, op);
/* Create 'set' operation */
op = operations_generate_set_operation (at);
if (op == NULL)
printf ("\noperations_getset_callback - 'set' operation could not be
created.");
else
/* Add operation to our local operation list */
list = g_list_append(list, op);
/* Iterate over the attribute list */
atributos = g_list_next(atributos);
}
/* Transfer list items to operations list */
gtk_list_append_items(umlclass->properties_dialog->operations_list, list);
}
Btw, I've also tried using this...
glist_append (umlclass->operations, op);
... after creating each operation. They get added to the list but somewhere
in the program they get deleted or overwritten.
Thank you very much for your time and effort.
Looking forward to hear from you,
Martin F.
----- End forwarded message -----
--
Fredrik Hallenberg hallon lysator liu se
http://www.lysator.liu.se/~hallon hallon debian org
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]