Commit 5d7d475b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

gegl/gegl-connection.[ch] gegl/gegl-eval-mgr.[ch] gegl/gegl-eval-visitor.c

2005-06-03  Michael Natterer  <mitch@gimp.org>

	* gegl/gegl-connection.[ch]
	* gegl/gegl-eval-mgr.[ch]
	* gegl/gegl-eval-visitor.c
	* gegl/gegl-filter.c
	* gegl/gegl-graph.[ch]
	* gegl/gegl-init.[ch]
	* gegl/gegl-node.[ch]
	* gegl/gegl-object.c
	* gegl/gegl-property.c
	* gegl/gegl-types.h
	* gegl/gegl-utils.[ch]
	* gegl/gegl-visitable.c
	* gegl/gegl-visitor.c
	* gegl/gegl.h: more cleanup.
parent eb5f011d
2005-06-03 Michael Natterer <mitch@gimp.org>
* gegl/gegl-connection.[ch]
* gegl/gegl-eval-mgr.[ch]
* gegl/gegl-eval-visitor.c
* gegl/gegl-filter.c
* gegl/gegl-graph.[ch]
* gegl/gegl-init.[ch]
* gegl/gegl-node.[ch]
* gegl/gegl-object.c
* gegl/gegl-property.c
* gegl/gegl-types.h
* gegl/gegl-utils.[ch]
* gegl/gegl-visitable.c
* gegl/gegl-visitor.c
* gegl/gegl.h: more cleanup.
2005-06-02 Sven Neumann <sven@gimp.org>
* gegl/image/gegl-component-sample-model.c
......
......@@ -30,23 +30,24 @@
struct _GeglConnection
{
GeglNode * sink;
GeglNode *sink;
GeglProperty *sink_prop;
GeglNode * source;
GeglNode *source;
GeglProperty *source_prop;
};
GeglConnection *
gegl_connection_new(GeglNode *sink,
GeglProperty *sink_prop,
GeglNode *source,
GeglProperty *source_prop)
gegl_connection_new (GeglNode *sink,
GeglProperty *sink_prop,
GeglNode *source,
GeglProperty *source_prop)
{
GeglConnection *connection = g_new(GeglConnection, 1);
connection->sink = sink;
connection->sink_prop = sink_prop;
connection->source = source;
GeglConnection *connection = g_new0 (GeglConnection, 1);
connection->sink = sink;
connection->sink_prop = sink_prop;
connection->source = source;
connection->source_prop = source_prop;
return connection;
......@@ -60,7 +61,7 @@ gegl_connection_get_source_node (GeglConnection *connection)
void
gegl_connection_set_source_node (GeglConnection *connection,
GeglNode *source)
GeglNode *source)
{
connection->source = source;
}
......@@ -73,7 +74,7 @@ gegl_connection_get_sink_node (GeglConnection *connection)
void
gegl_connection_set_sink_node (GeglConnection *connection,
GeglNode *sink)
GeglNode *sink)
{
connection->sink = sink;
}
......@@ -86,7 +87,7 @@ gegl_connection_get_sink_prop (GeglConnection *connection)
void
gegl_connection_set_sink_prop (GeglConnection *connection,
GeglProperty *sink_prop)
GeglProperty *sink_prop)
{
connection->sink_prop = sink_prop;
}
......@@ -99,7 +100,7 @@ gegl_connection_get_source_prop (GeglConnection *connection)
void
gegl_connection_set_source_prop (GeglConnection *connection,
GeglProperty *source_prop)
GeglProperty *source_prop)
{
connection->source_prop = source_prop;
}
......@@ -18,6 +18,7 @@
* Copyright 2003 Calvin Williamson
*
*/
#ifndef __GEGL_CONNECTION_H__
#define __GEGL_CONNECTION_H__
......
......@@ -56,22 +56,21 @@ gegl_eval_mgr_init (GeglEvalMgr *self)
* @property_name:
*
* Update this property.
*
**/
void
gegl_eval_mgr_apply (GeglEvalMgr * self,
gegl_eval_mgr_apply (GeglEvalMgr *self,
GeglNode *root,
const gchar *property_name)
{
GeglVisitor *visitor;
GeglVisitor *visitor;
GeglProperty *property;
g_return_if_fail (GEGL_IS_EVAL_MGR (self));
g_return_if_fail (GEGL_IS_NODE (root));
g_object_ref(root);
g_object_ref (root);
property = gegl_node_get_property(root, property_name);
property = gegl_node_get_property (root, property_name);
#if 0
/* This part does the evaluation of the ops, depth first. */
......@@ -80,9 +79,9 @@ gegl_eval_mgr_apply (GeglEvalMgr * self,
G_OBJECT_TYPE_NAME(root), root, property_name);
#endif
visitor = g_object_new(GEGL_TYPE_EVAL_VISITOR, NULL);
gegl_visitor_dfs_traverse(visitor, GEGL_VISITABLE(property));
g_object_unref(visitor);
visitor = g_object_new (GEGL_TYPE_EVAL_VISITOR, NULL);
gegl_visitor_dfs_traverse (visitor, GEGL_VISITABLE(property));
g_object_unref (visitor);
g_object_unref(root);
g_object_unref (root);
}
......@@ -18,6 +18,7 @@
* Copyright 2003 Calvin Williamson
*
*/
#ifndef __GEGL_EVAL_MGR_H__
#define __GEGL_EVAL_MGR_H__
......@@ -26,12 +27,12 @@
G_BEGIN_DECLS
#define GEGL_TYPE_EVAL_MGR (gegl_eval_mgr_get_type ())
#define GEGL_EVAL_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_EVAL_MGR, GeglEvalMgr))
#define GEGL_EVAL_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEGL_TYPE_EVAL_MGR, GeglEvalMgrClass))
#define GEGL_IS_EVAL_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_EVAL_MGR))
#define GEGL_IS_EVAL_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEGL_TYPE_EVAL_MGR))
#define GEGL_EVAL_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_EVAL_MGR, GeglEvalMgrClass))
#define GEGL_TYPE_EVAL_MGR (gegl_eval_mgr_get_type ())
#define GEGL_EVAL_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_EVAL_MGR, GeglEvalMgr))
#define GEGL_EVAL_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEGL_TYPE_EVAL_MGR, GeglEvalMgrClass))
#define GEGL_IS_EVAL_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_EVAL_MGR))
#define GEGL_IS_EVAL_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEGL_TYPE_EVAL_MGR))
#define GEGL_EVAL_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_EVAL_MGR, GeglEvalMgrClass))
typedef struct _GeglEvalMgrClass GeglEvalMgrClass;
......
......@@ -67,29 +67,31 @@ visit_property (GeglVisitor *visitor,
gegl_object_get_name(GEGL_OBJECT(filter)));
#endif
if(gegl_property_is_output(property))
if (gegl_property_is_output (property))
{
gboolean success;
const gchar *property_name = gegl_property_get_name(property);
success = gegl_filter_evaluate(filter, property_name);
const gchar *property_name = gegl_property_get_name (property);
gboolean success;
success = gegl_filter_evaluate (filter, property_name);
}
else if(gegl_property_is_input(property))
else if (gegl_property_is_input (property))
{
GeglProperty *source_prop = gegl_property_get_connected_to(property);
if(source_prop)
GeglProperty *source_prop = gegl_property_get_connected_to (property);
if (source_prop)
{
GValue value = {0};
GParamSpec *prop_spec = gegl_property_get_param_spec(property);
GeglFilter *source = gegl_property_get_filter(source_prop);
g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(prop_spec));
g_object_get_property(G_OBJECT(source),
gegl_property_get_name(source_prop),
&value);
g_object_set_property(G_OBJECT(filter),
gegl_property_get_name(property),
&value);
GValue value = { 0 };
GParamSpec *prop_spec = gegl_property_get_param_spec (property);
GeglFilter *source = gegl_property_get_filter (source_prop);
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop_spec));
g_object_get_property (G_OBJECT(source),
gegl_property_get_name (source_prop),
&value);
g_object_set_property (G_OBJECT (filter),
gegl_property_get_name (property),
&value);
}
}
}
......@@ -63,29 +63,31 @@ finalize (GObject *gobject)
* @param_spec:
*
* Create a property.
*
**/
void
gegl_filter_create_property(GeglFilter *self,
GParamSpec *param_spec)
gegl_filter_create_property (GeglFilter *self,
GParamSpec *param_spec)
{
GeglProperty * property;
g_return_if_fail(GEGL_IS_FILTER(self));
g_return_if_fail(param_spec);
GeglProperty *property;
g_return_if_fail (GEGL_IS_FILTER (self));
g_return_if_fail (param_spec);
property = g_object_new (GEGL_TYPE_PROPERTY, NULL);
gegl_property_set_param_spec(property, param_spec);
gegl_property_set_filter(property, self);
gegl_node_add_property(GEGL_NODE(self), property);
gegl_property_set_param_spec (property, param_spec);
gegl_property_set_filter (property, self);
gegl_node_add_property (GEGL_NODE (self), property);
}
gboolean
gegl_filter_evaluate (GeglFilter *self,
gegl_filter_evaluate (GeglFilter *self,
const gchar *output_prop)
{
GeglFilterClass *klass;
g_return_val_if_fail (GEGL_IS_FILTER (self), FALSE);
klass = GEGL_FILTER_GET_CLASS(self);
return klass->evaluate(self, output_prop);
klass = GEGL_FILTER_GET_CLASS (self);
return klass->evaluate (self, output_prop);
}
......@@ -30,21 +30,21 @@
#include "gegl-property.h"
#include "gegl-visitor.h"
enum
{
PROP_0,
PROP_LAST
PROP_0
};
static void gegl_graph_class_init (GeglGraphClass *klass);
static void gegl_graph_init (GeglGraph *self);
static void finalize (GObject *gobject);
static void set_property (GObject *gobject,
guint prop_id,
static void finalize (GObject *object);
static void set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void get_property (GObject *gobject,
guint prop_id,
static void get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
......@@ -55,11 +55,11 @@ G_DEFINE_TYPE(GeglGraph, gegl_graph, GEGL_TYPE_NODE)
static void
gegl_graph_class_init (GeglGraphClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = finalize;
gobject_class->set_property = set_property;
gobject_class->get_property = get_property;
object_class->finalize = finalize;
object_class->set_property = set_property;
object_class->get_property = get_property;
}
static void
......@@ -69,9 +69,9 @@ gegl_graph_init (GeglGraph *self)
}
static void
finalize(GObject *gobject)
finalize (GObject *object)
{
GeglGraph *self = GEGL_GRAPH (gobject);
GeglGraph *self = GEGL_GRAPH (object);
GeglNode *node = GEGL_NODE (self);
while (node->properties)
......@@ -83,45 +83,48 @@ finalize(GObject *gobject)
gegl_graph_remove_children (self);
G_OBJECT_CLASS (gegl_graph_parent_class)->finalize (gobject);
G_OBJECT_CLASS (gegl_graph_parent_class)->finalize (object);
}
static void
set_property (GObject *gobject,
guint prop_id,
set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
}
static void
get_property (GObject *gobject,
guint prop_id,
get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
}
void
gegl_graph_remove_children(GeglGraph *self)
gegl_graph_remove_children (GeglGraph *self)
{
g_return_if_fail (GEGL_IS_GRAPH (self));
while(1)
while (TRUE)
{
GeglNode *child = gegl_graph_get_nth_child(self, 0);
GeglNode *child = gegl_graph_get_nth_child (self, 0);
if(child)
gegl_graph_remove_child(self, child);
if (child)
gegl_graph_remove_child (self, child);
else
break;
}
......@@ -133,8 +136,9 @@ gegl_graph_add_child (GeglGraph *self,
{
g_return_val_if_fail (GEGL_IS_GRAPH (self), NULL);
g_return_val_if_fail (GEGL_IS_NODE (child), NULL);
self->children = g_list_append(self->children, child);
g_object_ref(child);
self->children = g_list_append (self->children, g_object_ref (child));
return child;
}
......@@ -144,8 +148,10 @@ gegl_graph_remove_child (GeglGraph *self,
{
g_return_val_if_fail (GEGL_IS_GRAPH (self), NULL);
g_return_val_if_fail (GEGL_IS_NODE (child), NULL);
self->children = g_list_remove(self->children, child);
g_object_unref(child);
self->children = g_list_remove (self->children, child);
g_object_unref (child);
return child;
}
......@@ -153,21 +159,23 @@ gint
gegl_graph_num_children (GeglGraph *self)
{
g_return_val_if_fail (GEGL_IS_GRAPH (self), -1);
return g_list_length(self->children);
}
return g_list_length (self->children);
}
GeglNode *
gegl_graph_get_nth_child (GeglGraph *self,
gint n)
{
g_return_val_if_fail (GEGL_IS_GRAPH (self), NULL);
return g_list_nth_data(self->children, n);
return g_list_nth_data (self->children, n);
}
GList *
gegl_graph_get_children (GeglGraph *self)
gegl_graph_get_children (GeglGraph *self)
{
g_return_val_if_fail (GEGL_IS_GRAPH (self), NULL);
return self->children;
}
......@@ -18,6 +18,7 @@
* Copyright 2003 Calvin Williamson
*
*/
#ifndef __GEGL_GRAPH_H__
#define __GEGL_GRAPH_H__
......
/*
* This file is part of GEGL.
*
......@@ -22,15 +21,15 @@
#include "config.h"
#include <glib-object.h>
#include "gegl-types.h"
#include "gegl-init.h"
static gboolean gegl_initialized = FALSE;
static
void
gegl_exit(void)
{
}
void
gegl_init (int *argc,
......@@ -39,6 +38,10 @@ gegl_init (int *argc,
if (gegl_initialized)
return;
g_atexit(gegl_exit);
gegl_initialized = TRUE;
}
void
gegl_exit (void)
{
}
......@@ -18,11 +18,18 @@
* Copyright 2003 Calvin Williamson
*
*/
#ifndef __GEGL_INIT_H__
#define __GEGL_INIT_H__
#include <glib-object.h>
G_BEGIN_DECLS
void gegl_init (gint *argc,
gchar ***argv);
void gegl_exit (void);
void gegl_init (int *argc, char ***argv);
G_END_DECLS
#endif /* __GEGL_INIT_H__ */
This diff is collapsed.
......@@ -58,36 +58,36 @@ struct _GeglNodeClass
};
GType gegl_node_get_type (void) G_GNUC_CONST;
void gegl_node_add_property (GeglNode *self,
GeglProperty *property);
void gegl_node_remove_property (GeglNode *self,
GeglProperty *property);
GeglProperty *gegl_node_get_property (GeglNode *self,
const gchar *name);
GList* gegl_node_get_properties (GeglNode *self);
GList* gegl_node_get_input_properties (GeglNode *self);
GList* gegl_node_get_output_properties (GeglNode *self);
gint gegl_node_get_num_input_props (GeglNode *self);
gint gegl_node_get_num_output_props (GeglNode *self);
GList* gegl_node_get_sinks (GeglNode *self);
GList* gegl_node_get_sources (GeglNode *self);
gint gegl_node_num_sources (GeglNode *self);
gint gegl_node_num_sinks (GeglNode *self);
gboolean gegl_node_connect (GeglNode *sink,
const gchar *sink_prop_name,
GeglNode *source,
const gchar *source_prop_name);
gboolean gegl_node_disconnect (GeglNode *sink,
const gchar *sink_prop_name,
GeglNode *source,
const gchar *source_prop_name);
void gegl_node_disconnect_sinks (GeglNode *self);
void gegl_node_disconnect_sources (GeglNode *self);
GList* gegl_node_get_depends_on (GeglNode *self);
void gegl_node_apply (GeglNode *self,
const gchar *output_prop_name);
GType gegl_node_get_type (void) G_GNUC_CONST;
void gegl_node_add_property (GeglNode *self,
GeglProperty *property);
void gegl_node_remove_property (GeglNode *self,
GeglProperty *property);
GeglProperty * gegl_node_get_property (GeglNode *self,
const gchar *name);
GList * gegl_node_get_properties (GeglNode *self);
GList * gegl_node_get_input_properties (GeglNode *self);
GList * gegl_node_get_output_properties (GeglNode *self);
gint gegl_node_get_num_input_props (GeglNode *self);
gint gegl_node_get_num_output_props (GeglNode *self);
GList * gegl_node_get_sinks (GeglNode *self);
GList * gegl_node_get_sources (GeglNode *self);
gint gegl_node_num_sources (GeglNode *self);
gint gegl_node_num_sinks (GeglNode *self);
gboolean gegl_node_connect (GeglNode *sink,
const gchar *sink_prop_name,
GeglNode *source,
const gchar *source_prop_name);
gboolean gegl_node_disconnect (GeglNode *sink,
const gchar *sink_prop_name,
GeglNode *source,
const gchar *source_prop_name);
void gegl_node_disconnect_sinks (GeglNode *self);
void gegl_node_disconnect_sources (GeglNode *self);
GList * gegl_node_get_depends_on (GeglNode *self);
void gegl_node_apply (GeglNode *self,
const gchar *output_prop_name);
G_END_DECLS
......
......@@ -34,20 +34,20 @@ enum
PROP_NAME
};
static void gegl_object_class_init (GeglObjectClass *klass);
static void gegl_object_init (GeglObject *self);
static GObject* constructor (GType type,
guint n_props,
GObjectConstructParam *props);
static void finalize (GObject *gobject);
static void set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gegl_object_class_init (GeglObjectClass *klass);
static void gegl_object_init (GeglObject *self);
static GObject * constructor (GType type,
guint n_props,
GObjectConstructParam *props);
static void finalize (GObject *gobject);
static void set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GeglObject, gegl_object, G_TYPE_OBJECT)
......@@ -58,8 +58,8 @@ gegl_object_class_init (GeglObjectClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->constructor = constructor;
gobject_class->finalize = finalize;
gobject_class->constructor = constructor;
gobject_class->finalize = finalize;
gobject_class->set_property = set_property;
gobject_class->get_property = get_property;
......@@ -70,7 +70,6 @@ gegl_object_class_init (GeglObjectClass * klass)
"",
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE));
}
static void
......@@ -80,12 +79,12 @@ gegl_object_init (GeglObject *self)
}
static void
finalize(GObject *gobject)
finalize (GObject *gobject)
{
GeglObject * self = GEGL_OBJECT(gobject);
GeglObject * self = GEGL_OBJECT (gobject);
if(self->name)
g_free(self->name);
if (self->name)
g_free (self->name);
G_OBJECT_CLASS (gegl_object_parent_class)->finalize (gobject);
}
......@@ -95,45 +94,56 @@ constructor (GType type,
guint n_props,
GObjectConstructParam *props)
{
GObjectClass *class = G_OBJECT_CLASS (gegl_object_parent_class);
GObject *gobject = class->constructor (type, n_props, props);
GeglObject *self = GEGL_OBJECT(gobject);
GObject *object;
GeglObject *self;
object = G_OBJECT_CLASS (gegl_object_parent_class)->constructor (type,
n_props,
props);
self = GEGL_OBJECT (object);
self->constructed = TRUE;
return gobject;
return object;
}
static void
set_property (GObject *gobject,
guint prop_id,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GeglObject * object = GEGL_OBJECT(gobject);
switch (prop_id)
{
GeglObject *object = GEGL_OBJECT (gobject);
switch (property_id)
{
case PROP_NAME:
gegl_object_set_name(object, g_value_get_string(value));
gegl_object_set_name (object, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
}
static void
get_property (GObject *gobject,
guint prop_id,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GeglObject * object = GEGL_OBJECT(gobject);
switch (prop_id)
{
GeglObject *object = GEGL_OBJECT (gobject);
switch (property_id)
{
case PROP_NAME:
g_value_set_string(value, gegl_object_get_name(object));
g_value_set_string (value, gegl_object_get_name (object));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
}
/**
......@@ -142,15 +152,19 @@ get_property (GObject *gobject,
* @name: a string
*
* Sets the name for this object.
*
**/
void
gegl_object_set_name (GeglObject * self,
const gchar * name)
gegl_object_set_name (GeglObject *self,
const gchar *name)
{
g_return_if_fail (GEGL_IS_OBJECT (self));
self->name = g_strdup(name);
if (self->name)
g_free (self->name);
self->name = g_strdup (name);
g_object_notify (G_OBJECT (self), "name");
}
/**
......@@ -161,7 +175,7 @@ gegl_object_set_name (GeglObject * self,
*
* Returns: a string for the name of this object.
**/
G_CONST_RETURN gchar*
const gchar*
gegl_object_get_name (GeglObject * self)
{
g_return_val_if_fail (GEGL_IS_OBJECT (self), NULL);
......
......@@ -63,29 +63,31 @@ finalize (GObject *gobject)