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


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


#define TYPE_PROVIDER (provider_get_type ())
#define PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PROVIDER, Provider))
#define PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PROVIDER, ProviderClass))
#define IS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PROVIDER))
#define IS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PROVIDER))
#define PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PROVIDER, ProviderClass))

typedef struct _Provider Provider;
typedef struct _ProviderClass ProviderClass;
typedef struct _ProviderPrivate ProviderPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _Provider {
	GObject parent_instance;
	ProviderPrivate * priv;
};

struct _ProviderClass {
	GObjectClass parent_class;
	void (*update) (Provider* self);
};

struct _ProviderPrivate {
	gchar* _id;
	gchar** _keys;
	gint _keys_length1;
	gint __keys_size_;
	gchar _displaytype;
	gdouble* _values;
	gint _values_length1;
	gint __values_size_;
};


static gpointer provider_parent_class = NULL;

GType provider_get_type (void) G_GNUC_CONST;
#define PROVIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PROVIDER, ProviderPrivate))
enum  {
	PROVIDER_DUMMY_PROPERTY,
	PROVIDER_ID,
	PROVIDER_KEYS,
	PROVIDER_DISPLAYTYPE
};
Provider* provider_construct (GType object_type, const gchar* id, gchar** keys, int keys_length1, gchar displaytype);
void provider_update (Provider* self);
static void provider_real_update (Provider* self);
const gchar* provider_get_id (Provider* self);
static void provider_set_id (Provider* self, const gchar* value);
gchar** provider_get_keys (Provider* self, int* result_length1);
static void provider_set_keys (Provider* self, gchar** value, int value_length1);
static gchar** _vala_array_dup25 (gchar** self, int length);
gchar provider_get_displaytype (Provider* self);
static void provider_set_displaytype (Provider* self, gchar value);
gdouble* provider_get_values (Provider* self, int* result_length1);
static void provider_set_values (Provider* self, gdouble* value, int value_length1);
static gdouble* _vala_array_dup26 (gdouble* self, int length);
static GObject * provider_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void provider_finalize (GObject* obj);
static void _vala_provider_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_provider_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);


Provider* provider_construct (GType object_type, const gchar* id, gchar** keys, int keys_length1, gchar displaytype) {
	Provider * self = NULL;
	const gchar* _tmp0_ = NULL;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	gchar _tmp2_ = '\0';
	g_return_val_if_fail (id != NULL, NULL);
	_tmp0_ = id;
	_tmp1_ = keys;
	_tmp1__length1 = keys_length1;
	_tmp2_ = displaytype;
	self = (Provider*) g_object_new (object_type, "id", _tmp0_, "keys", _tmp1_, "displaytype", _tmp2_, NULL);
	return self;
}


static void provider_real_update (Provider* self) {
	g_critical ("Type `%s' does not implement abstract method `provider_update'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}


void provider_update (Provider* self) {
	g_return_if_fail (IS_PROVIDER (self));
	PROVIDER_GET_CLASS (self)->update (self);
}


const gchar* provider_get_id (Provider* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (IS_PROVIDER (self), NULL);
	_tmp0_ = self->priv->_id;
	result = _tmp0_;
	return result;
}


static void provider_set_id (Provider* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (IS_PROVIDER (self));
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_id);
	self->priv->_id = _tmp1_;
	g_object_notify ((GObject *) self, "id");
}


gchar** provider_get_keys (Provider* self, int* result_length1) {
	gchar** result;
	gchar** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_val_if_fail (IS_PROVIDER (self), NULL);
	_tmp0_ = self->priv->_keys;
	_tmp0__length1 = self->priv->_keys_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}


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


static void provider_set_keys (Provider* self, gchar** value, int value_length1) {
	gchar** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_if_fail (IS_PROVIDER (self));
	_tmp0_ = value;
	_tmp0__length1 = value_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup25 (_tmp0_, _tmp0__length1) : ((gpointer) _tmp0_);
	_tmp1__length1 = _tmp0__length1;
	self->priv->_keys = (_vala_array_free (self->priv->_keys, self->priv->_keys_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_keys = _tmp1_;
	self->priv->_keys_length1 = _tmp1__length1;
	self->priv->__keys_size_ = self->priv->_keys_length1;
	g_object_notify ((GObject *) self, "keys");
}


gchar provider_get_displaytype (Provider* self) {
	gchar result;
	gchar _tmp0_ = '\0';
	g_return_val_if_fail (IS_PROVIDER (self), '\0');
	_tmp0_ = self->priv->_displaytype;
	result = _tmp0_;
	return result;
}


static void provider_set_displaytype (Provider* self, gchar value) {
	gchar _tmp0_ = '\0';
	g_return_if_fail (IS_PROVIDER (self));
	_tmp0_ = value;
	self->priv->_displaytype = _tmp0_;
	g_object_notify ((GObject *) self, "displaytype");
}


gdouble* provider_get_values (Provider* self, int* result_length1) {
	gdouble* result;
	gdouble* _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gdouble* _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_val_if_fail (IS_PROVIDER (self), NULL);
	_tmp0_ = self->priv->_values;
	_tmp0__length1 = self->priv->_values_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}


static gdouble* _vala_array_dup26 (gdouble* self, int length) {
	return g_memdup (self, length * sizeof (gdouble));
}


static void provider_set_values (Provider* self, gdouble* value, int value_length1) {
	gdouble* _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gdouble* _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_if_fail (IS_PROVIDER (self));
	_tmp0_ = value;
	_tmp0__length1 = value_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup26 (_tmp0_, _tmp0__length1) : ((gpointer) _tmp0_);
	_tmp1__length1 = _tmp0__length1;
	self->priv->_values = (g_free (self->priv->_values), NULL);
	self->priv->_values = _tmp1_;
	self->priv->_values_length1 = _tmp1__length1;
	self->priv->__values_size_ = self->priv->_values_length1;
}


static GObject * provider_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	Provider * self;
	gchar** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	gdouble* _tmp2_ = NULL;
	gdouble* _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	parent_class = G_OBJECT_CLASS (provider_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PROVIDER, Provider);
	_tmp0_ = provider_get_keys (self, &_tmp0__length1);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = g_new0 (gdouble, _tmp1__length1);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = _tmp1__length1;
	provider_set_values (self, _tmp3_, _tmp1__length1);
	_tmp3_ = (g_free (_tmp3_), NULL);
	return obj;
}


static void provider_class_init (ProviderClass * klass) {
	provider_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ProviderPrivate));
	PROVIDER_CLASS (klass)->update = provider_real_update;
	G_OBJECT_CLASS (klass)->get_property = _vala_provider_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_provider_set_property;
	G_OBJECT_CLASS (klass)->constructor = provider_constructor;
	G_OBJECT_CLASS (klass)->finalize = provider_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROVIDER_ID, g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROVIDER_KEYS, g_param_spec_boxed ("keys", "keys", "keys", G_TYPE_STRV, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROVIDER_DISPLAYTYPE, g_param_spec_char ("displaytype", "displaytype", "displaytype", G_MININT8, G_MAXINT8, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void provider_instance_init (Provider * self) {
	self->priv = PROVIDER_GET_PRIVATE (self);
}


static void provider_finalize (GObject* obj) {
	Provider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PROVIDER, Provider);
	_g_free0 (self->priv->_id);
	self->priv->_keys = (_vala_array_free (self->priv->_keys, self->priv->_keys_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_values = (g_free (self->priv->_values), NULL);
	G_OBJECT_CLASS (provider_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 provider_get_type (void) {
	static volatile gsize provider_type_id__volatile = 0;
	if (g_once_init_enter (&provider_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Provider), 0, (GInstanceInitFunc) provider_instance_init, NULL };
		GType provider_type_id;
		provider_type_id = g_type_register_static (G_TYPE_OBJECT, "Provider", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
		g_once_init_leave (&provider_type_id__volatile, provider_type_id);
	}
	return provider_type_id__volatile;
}


static void _vala_provider_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	Provider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_PROVIDER, Provider);
	switch (property_id) {
		case PROVIDER_ID:
		g_value_set_string (value, provider_get_id (self));
		break;
		case PROVIDER_KEYS:
		{
			int length;
			g_value_set_boxed (value, provider_get_keys (self, &length));
		}
		break;
		case PROVIDER_DISPLAYTYPE:
		g_value_set_char (value, provider_get_displaytype (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_provider_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	Provider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_PROVIDER, Provider);
	switch (property_id) {
		case PROVIDER_ID:
		provider_set_id (self, g_value_get_string (value));
		break;
		case PROVIDER_KEYS:
		{
			gpointer boxed;
			boxed = g_value_get_boxed (value);
			provider_set_keys (self, boxed, g_strv_length (boxed));
		}
		break;
		case PROVIDER_DISPLAYTYPE:
		provider_set_displaytype (self, g_value_get_char (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);
}



