RSS/Atom feed Twitter
Site is read-only, email is disabled

node creation API

This discussion is connected to the gegl-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

node creation API Victor Bogado 01 Sep 14:39
node creation API Øyvind Kolås 01 Sep 15:03
node creation API Øyvind Kolås 01 Sep 16:17
Victor Bogado
2006-09-01 14:39:05 UTC (about 18 years ago)

node creation API

It seems to me that when creating a gegl_node the user will always set the class, and more he will need to this before setting any other property.

Since this is always required why do he need to state this verbosely? I mean, look at this code, from the gegl-demo :

---- anim.c ---- GeglGraph *gegl = g_object_new (GEGL_TYPE_GRAPH, NULL);

GeglNode *display = gegl_graph_create_node (gegl, "class", "display", "window_title", "GEGL demo", NULL);
GeglNode *background = gegl_graph_create_node (gegl, "class", "jpg-load", "path", "data/vinci-womb.jpg", "name", "background", NULL);
GeglNode *load = gegl_graph_create_node (gegl, "class", "png-load", "path", "data/gegl.png", NULL);
--------

I think that this function should receive the "class" as a first parameter. So this would become :

---- alternative.c ---- GeglGraph *gegl = g_object_new (GEGL_TYPE_GRAPH, NULL);

GeglNode *display = gegl_graph_create_node (gegl, "display", "window_title", "GEGL demo", NULL);
GeglNode *background = gegl_graph_create_node (gegl, "jpg-load", "path", "data/vinci-womb.jpg", "name", "background", NULL);
--------

This would not only keep the string "class" from appearing several times in the code, but it would prevent the user from committing the mistake of not setting the class, or setting the class out of the order.

Øyvind Kolås
2006-09-01 15:03:51 UTC (about 18 years ago)

node creation API

On 9/1/06, Victor Bogado wrote:

It seems to me that when creating a gegl_node the user will always set the class, and more he will need to this before setting any other property.

Since this is always required why do he need to state this verbosely? I mean, look at this code, from the gegl-demo :

GeglNode *background = gegl_graph_create_node (gegl, "class", "jpg-load", "path", "data/vinci-womb.jpg", "name", "background", NULL);

I think that this function should receive the "class" as a first parameter. So this would become :

GeglNode *background = gegl_graph_create_node (gegl, "jpg-load", "path", "data/vinci-womb.jpg", "name", "background", NULL);

This would not only keep the string "class" from appearing several times in the code, but it would prevent the user from committing the mistake of not setting the class, or setting the class out of the order.

gegl_graph_create_node and gegl_node_set currently have the same constraint that class should appear as the first key/value pair if it is present (it is mandatory for gegl_graph_create_node). Making the API for these diverge is probably not a good thing to do. If GEGL doesn't already complain if the class is not the first property being set, it should be changed to do so.

Allowing to change the "class" of a node (it might be better to rename this to either "type" or "operation") is a design decision that makes it a lot easier to change what kind of processing is done without having to replace the node in the graph (and thus rewire the connections).

/Øyvind K.

Øyvind Kolås
2006-09-01 16:17:51 UTC (about 18 years ago)

node creation API

I'm not sure the name gegl_graph_create_node is very good either, if it was possible to come up with a shorter name that describes what it does I think it would be better. Perhaps gegl_graph_new_node or gegl_graph_node_new? (only two letters shorter, but I think it conveys the result just as well).

On 9/1/06, Victor Bogado wrote:

I want to update my binding, so it will match the API in C, the closer the better. But with "class" as a property it is impossible. This kind of change, that has a large impact, it is better to be done sooner then latter, so I would volunteer to change it now and send the diff.

Another option would be to not allow passing additional properties to the node creation method perhaps turn it into:

GeglNode *gegl_graph_new_node (GeglGraph *graph, const gchar *operation);

blur = gegl_graph_new_node (graph, "gaussian-blur"); gegl_node_set (blur,
"radius", 1.5,
NULL);

Or even strip even everything but the graph parameter to the function and always assume that a virgin node has a nop operation associated.)

blur = gegl_graph_new_node (graph); gegl_node_set (blur,
"operation", "gaussian-blur",
"radius", 1.5,
NULL);

This is probably not a good idea though, since it would increase the amount of typing needed.

What would you prefer "type" or "operation"? I prefer "operation", because it is more explicit that this is what the node is doing and also it is more consistent with the internals, since it is defining what gegl_operation that node contains.

I prefer "operation" as well.

/Øyvind K.

(I reply back to the mailing-list and not only to you, presuming that it was a mistake when replying.)