/* graphmodels.c generated by valac 0.22.1, the Vala compiler
 * generated from graphmodels.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_GRAPH_MODELS (graph_models_get_type ())
#define GRAPH_MODELS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GRAPH_MODELS, GraphModels))
#define GRAPH_MODELS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GRAPH_MODELS, GraphModelsClass))
#define IS_GRAPH_MODELS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GRAPH_MODELS))
#define IS_GRAPH_MODELS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GRAPH_MODELS))
#define GRAPH_MODELS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GRAPH_MODELS, GraphModelsClass))

typedef struct _GraphModels GraphModels;
typedef struct _GraphModelsClass GraphModelsClass;
typedef struct _GraphModelsPrivate GraphModelsPrivate;

#define TYPE_PROVIDERS (providers_get_type ())
#define PROVIDERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PROVIDERS, Providers))
#define PROVIDERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PROVIDERS, ProvidersClass))
#define IS_PROVIDERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PROVIDERS))
#define IS_PROVIDERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PROVIDERS))
#define PROVIDERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PROVIDERS, ProvidersClass))

typedef struct _Providers Providers;
typedef struct _ProvidersClass ProvidersClass;

#define TYPE_GRAPH_MODEL (graph_model_get_type ())
#define GRAPH_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GRAPH_MODEL, GraphModel))
#define GRAPH_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GRAPH_MODEL, GraphModelClass))
#define IS_GRAPH_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GRAPH_MODEL))
#define IS_GRAPH_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GRAPH_MODEL))
#define GRAPH_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GRAPH_MODEL, GraphModelClass))

typedef struct _GraphModel GraphModel;
typedef struct _GraphModelClass GraphModelClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GraphModels {
	GObject parent_instance;
	GraphModelsPrivate * priv;
};

struct _GraphModelsClass {
	GObjectClass parent_class;
};

struct _GraphModelsPrivate {
	Providers* _providers;
	GraphModel** _graphmodels;
	gint _graphmodels_length1;
	gint __graphmodels_size_;
};


static gpointer graph_models_parent_class = NULL;

GType graph_models_get_type (void) G_GNUC_CONST;
GType providers_get_type (void) G_GNUC_CONST;
GType graph_model_get_type (void) G_GNUC_CONST;
#define GRAPH_MODELS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_GRAPH_MODELS, GraphModelsPrivate))
enum  {
	GRAPH_MODELS_DUMMY_PROPERTY,
	GRAPH_MODELS_PROVIDERS
};
GraphModels* graph_models_new (gchar** graphids, int graphids_length1, Providers* providers);
GraphModels* graph_models_construct (GType object_type, gchar** graphids, int graphids_length1, Providers* providers);
Providers* graph_models_get_providers (GraphModels* self);
GraphModel* graph_model_new (const gchar* id, Providers* providers);
GraphModel* graph_model_construct (GType object_type, const gchar* id, Providers* providers);
static void _vala_array_add9 (GraphModel*** array, int* length, int* size, GraphModel* value);
void graph_models_update (GraphModels* self, guint trace_length);
GraphModel** graph_models_get_graphmodels (GraphModels* self, int* result_length1);
void graph_model_update (GraphModel* self, guint trace_length);
static void graph_models_set_providers (GraphModels* self, Providers* value);
static void graph_models_set_graphmodels (GraphModels* self, GraphModel** value, int value_length1);
static GraphModel** _vala_array_dup9 (GraphModel** self, int length);
static void graph_models_finalize (GObject* obj);
static void _vala_graph_models_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_graph_models_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static void _vala_array_add9 (GraphModel*** array, int* length, int* size, GraphModel* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GraphModel*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


GraphModels* graph_models_construct (GType object_type, gchar** graphids, int graphids_length1, Providers* providers) {
	GraphModels * self = NULL;
	Providers* _tmp0_ = NULL;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_val_if_fail (IS_PROVIDERS (providers), NULL);
	_tmp0_ = providers;
	self = (GraphModels*) g_object_new (object_type, "providers", _tmp0_, NULL);
	_tmp1_ = graphids;
	_tmp1__length1 = graphids_length1;
	{
		gchar** graphid_collection = NULL;
		gint graphid_collection_length1 = 0;
		gint _graphid_collection_size_ = 0;
		gint graphid_it = 0;
		graphid_collection = _tmp1_;
		graphid_collection_length1 = _tmp1__length1;
		for (graphid_it = 0; graphid_it < _tmp1__length1; graphid_it = graphid_it + 1) {
			gchar* _tmp2_ = NULL;
			gchar* graphid = NULL;
			_tmp2_ = g_strdup (graphid_collection[graphid_it]);
			graphid = _tmp2_;
			{
				GraphModel** _tmp3_ = NULL;
				gint _tmp3__length1 = 0;
				const gchar* _tmp4_ = NULL;
				Providers* _tmp5_ = NULL;
				GraphModel* _tmp6_ = NULL;
				_tmp3_ = self->priv->_graphmodels;
				_tmp3__length1 = self->priv->_graphmodels_length1;
				_tmp4_ = graphid;
				_tmp5_ = self->priv->_providers;
				_tmp6_ = graph_model_new (_tmp4_, _tmp5_);
				_vala_array_add9 (&self->priv->_graphmodels, &self->priv->_graphmodels_length1, &self->priv->__graphmodels_size_, _tmp6_);
				_g_free0 (graphid);
			}
		}
	}
	return self;
}


GraphModels* graph_models_new (gchar** graphids, int graphids_length1, Providers* providers) {
	return graph_models_construct (TYPE_GRAPH_MODELS, graphids, graphids_length1, providers);
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


void graph_models_update (GraphModels* self, guint trace_length) {
	GraphModel** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	GraphModel** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_if_fail (IS_GRAPH_MODELS (self));
	_tmp0_ = graph_models_get_graphmodels (self, &_tmp0__length1);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	{
		GraphModel** graphmodel_collection = NULL;
		gint graphmodel_collection_length1 = 0;
		gint _graphmodel_collection_size_ = 0;
		gint graphmodel_it = 0;
		graphmodel_collection = _tmp1_;
		graphmodel_collection_length1 = _tmp1__length1;
		for (graphmodel_it = 0; graphmodel_it < _tmp1__length1; graphmodel_it = graphmodel_it + 1) {
			GraphModel* _tmp2_ = NULL;
			GraphModel* graphmodel = NULL;
			_tmp2_ = _g_object_ref0 (graphmodel_collection[graphmodel_it]);
			graphmodel = _tmp2_;
			{
				GraphModel* _tmp3_ = NULL;
				guint _tmp4_ = 0U;
				_tmp3_ = graphmodel;
				_tmp4_ = trace_length;
				graph_model_update (_tmp3_, _tmp4_);
				_g_object_unref0 (graphmodel);
			}
		}
	}
}


Providers* graph_models_get_providers (GraphModels* self) {
	Providers* result;
	Providers* _tmp0_ = NULL;
	g_return_val_if_fail (IS_GRAPH_MODELS (self), NULL);
	_tmp0_ = self->priv->_providers;
	result = _tmp0_;
	return result;
}


static void graph_models_set_providers (GraphModels* self, Providers* value) {
	Providers* _tmp0_ = NULL;
	Providers* _tmp1_ = NULL;
	g_return_if_fail (IS_GRAPH_MODELS (self));
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_providers);
	self->priv->_providers = _tmp1_;
	g_object_notify ((GObject *) self, "providers");
}


GraphModel** graph_models_get_graphmodels (GraphModels* self, int* result_length1) {
	GraphModel** result;
	GraphModel** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	GraphModel** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_val_if_fail (IS_GRAPH_MODELS (self), NULL);
	_tmp0_ = self->priv->_graphmodels;
	_tmp0__length1 = self->priv->_graphmodels_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}


static GraphModel** _vala_array_dup9 (GraphModel** self, int length) {
	GraphModel** result;
	int i;
	result = g_new0 (GraphModel*, length + 1);
	for (i = 0; i < length; i++) {
		GraphModel* _tmp0_ = NULL;
		_tmp0_ = _g_object_ref0 (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


static void graph_models_set_graphmodels (GraphModels* self, GraphModel** value, int value_length1) {
	GraphModel** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	GraphModel** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_if_fail (IS_GRAPH_MODELS (self));
	_tmp0_ = value;
	_tmp0__length1 = value_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup9 (_tmp0_, _tmp0__length1) : ((gpointer) _tmp0_);
	_tmp1__length1 = _tmp0__length1;
	self->priv->_graphmodels = (_vala_array_free (self->priv->_graphmodels, self->priv->_graphmodels_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->_graphmodels = _tmp1_;
	self->priv->_graphmodels_length1 = _tmp1__length1;
	self->priv->__graphmodels_size_ = self->priv->_graphmodels_length1;
}


static void graph_models_class_init (GraphModelsClass * klass) {
	graph_models_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GraphModelsPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_graph_models_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graph_models_set_property;
	G_OBJECT_CLASS (klass)->finalize = graph_models_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPH_MODELS_PROVIDERS, g_param_spec_object ("providers", "providers", "providers", TYPE_PROVIDERS, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void graph_models_instance_init (GraphModels * self) {
	self->priv = GRAPH_MODELS_GET_PRIVATE (self);
}


static void graph_models_finalize (GObject* obj) {
	GraphModels * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_GRAPH_MODELS, GraphModels);
	_g_object_unref0 (self->priv->_providers);
	self->priv->_graphmodels = (_vala_array_free (self->priv->_graphmodels, self->priv->_graphmodels_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (graph_models_parent_class)->finalize (obj);
}


/******************************************************************************
 * Copyright (C) 2011-2013  Michael Hofmann <mh21@mh21.de>                    *
 *                                                                            *
 * This program is free software; you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by       *
 * the Free Software Foundation; either version 3 of the License, or          *
 * (at your option) any later version.                                        *
 *                                                                            *
 * This program is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU General Public License for more details.                               *
 *                                                                            *
 * You should have received a copy of the GNU General Public License along    *
 * with this program; if not, write to the Free Software Foundation, Inc.,    *
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                *
 ******************************************************************************/
GType graph_models_get_type (void) {
	static volatile gsize graph_models_type_id__volatile = 0;
	if (g_once_init_enter (&graph_models_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GraphModelsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graph_models_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphModels), 0, (GInstanceInitFunc) graph_models_instance_init, NULL };
		GType graph_models_type_id;
		graph_models_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphModels", &g_define_type_info, 0);
		g_once_init_leave (&graph_models_type_id__volatile, graph_models_type_id);
	}
	return graph_models_type_id__volatile;
}


static void _vala_graph_models_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GraphModels * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_GRAPH_MODELS, GraphModels);
	switch (property_id) {
		case GRAPH_MODELS_PROVIDERS:
		g_value_set_object (value, graph_models_get_providers (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_graph_models_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GraphModels * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_GRAPH_MODELS, GraphModels);
	switch (property_id) {
		case GRAPH_MODELS_PROVIDERS:
		graph_models_set_providers (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



