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

#include "livechart.h"
#include <glib.h>
#include <string.h>
#include <gee.h>
#include <float.h>
#include <math.h>
#include <glib-object.h>

enum  {
	LIVE_CHART_VALUES_0_PROPERTY,
	LIVE_CHART_VALUES_BOUNDS_PROPERTY,
	LIVE_CHART_VALUES_NUM_PROPERTIES
};
static GParamSpec* live_chart_values_properties[LIVE_CHART_VALUES_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _live_chart_timestamped_value_free0(var) ((var == NULL) ? NULL : (var = (live_chart_timestamped_value_free (var), NULL)))

struct _LiveChartValuesPrivate {
	LiveChartBounds* _bounds;
	gint buffer_size;
};

static gint LiveChartValues_private_offset;
static gpointer live_chart_values_parent_class = NULL;

static void live_chart_values_finalize (GObject * obj);
static GType live_chart_values_get_type_once (void);
static void _vala_live_chart_values_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_live_chart_values_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

LiveChartTimestampedValue*
live_chart_timestamped_value_dup (const LiveChartTimestampedValue* self)
{
	LiveChartTimestampedValue* dup;
#line 5 "../src/values.vala"
	dup = g_new0 (LiveChartTimestampedValue, 1);
#line 5 "../src/values.vala"
	memcpy (dup, self, sizeof (LiveChartTimestampedValue));
#line 5 "../src/values.vala"
	return dup;
#line 53 "values.c"
}

void
live_chart_timestamped_value_free (LiveChartTimestampedValue* self)
{
#line 5 "../src/values.vala"
	g_free (self);
#line 61 "values.c"
}

static GType
live_chart_timestamped_value_get_type_once (void)
{
	GType live_chart_timestamped_value_type_id;
	live_chart_timestamped_value_type_id = g_boxed_type_register_static ("LiveChartTimestampedValue", (GBoxedCopyFunc) live_chart_timestamped_value_dup, (GBoxedFreeFunc) live_chart_timestamped_value_free);
	return live_chart_timestamped_value_type_id;
}

GType
live_chart_timestamped_value_get_type (void)
{
	static volatile gsize live_chart_timestamped_value_type_id__once = 0;
	if (g_once_init_enter (&live_chart_timestamped_value_type_id__once)) {
		GType live_chart_timestamped_value_type_id;
		live_chart_timestamped_value_type_id = live_chart_timestamped_value_get_type_once ();
		g_once_init_leave (&live_chart_timestamped_value_type_id__once, live_chart_timestamped_value_type_id);
	}
	return live_chart_timestamped_value_type_id__once;
}

static inline gpointer
live_chart_values_get_instance_private (LiveChartValues* self)
{
	return G_STRUCT_MEMBER_P (self, LiveChartValues_private_offset);
}

LiveChartValues*
live_chart_values_construct (GType object_type,
                             gint buffer_size)
{
	LiveChartValues * self = NULL;
	LiveChartBounds* _tmp0_;
	LiveChartBounds* _tmp1_;
#line 17 "../src/values.vala"
	self = (LiveChartValues*) gee_linked_list_construct (object_type, LIVE_CHART_TYPE_TIMESTAMPED_VALUE, (GBoxedCopyFunc) live_chart_timestamped_value_dup, (GDestroyNotify) live_chart_timestamped_value_free, NULL, NULL, NULL);
#line 18 "../src/values.vala"
	_tmp0_ = live_chart_bounds_new (((double) NAN), ((double) NAN));
#line 18 "../src/values.vala"
	_tmp1_ = _tmp0_;
#line 18 "../src/values.vala"
	live_chart_values_set_bounds (self, _tmp1_);
#line 18 "../src/values.vala"
	_g_object_unref0 (_tmp1_);
#line 19 "../src/values.vala"
	self->priv->buffer_size = buffer_size;
#line 17 "../src/values.vala"
	return self;
#line 111 "values.c"
}

LiveChartValues*
live_chart_values_new (gint buffer_size)
{
#line 17 "../src/values.vala"
	return live_chart_values_construct (LIVE_CHART_TYPE_VALUES, buffer_size);
#line 119 "values.c"
}

void
live_chart_values_add (LiveChartValues* self,
                       LiveChartTimestampedValue* value)
{
	gint _tmp0_;
	gint _tmp1_;
	LiveChartBounds* _tmp4_;
	LiveChartTimestampedValue _tmp5_;
	LiveChartTimestampedValue _tmp6_;
#line 22 "../src/values.vala"
	g_return_if_fail (self != NULL);
#line 22 "../src/values.vala"
	g_return_if_fail (value != NULL);
#line 23 "../src/values.vala"
	_tmp0_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) self);
#line 23 "../src/values.vala"
	_tmp1_ = _tmp0_;
#line 23 "../src/values.vala"
	if (_tmp1_ == self->priv->buffer_size) {
#line 141 "values.c"
		gpointer _tmp2_;
		LiveChartTimestampedValue* _tmp3_;
#line 24 "../src/values.vala"
		_tmp2_ = gee_abstract_list_remove_at ((GeeAbstractList*) self, 0);
#line 24 "../src/values.vala"
		_tmp3_ = (LiveChartTimestampedValue*) _tmp2_;
#line 24 "../src/values.vala"
		_live_chart_timestamped_value_free0 (_tmp3_);
#line 150 "values.c"
	}
#line 26 "../src/values.vala"
	_tmp4_ = self->priv->_bounds;
#line 26 "../src/values.vala"
	_tmp5_ = *value;
#line 26 "../src/values.vala"
	live_chart_bounds_update (_tmp4_, _tmp5_.value);
#line 27 "../src/values.vala"
	_tmp6_ = *value;
#line 27 "../src/values.vala"
	GEE_ABSTRACT_COLLECTION_CLASS (live_chart_values_parent_class)->add ((GeeAbstractCollection*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_LINKED_LIST, GeeLinkedList), &_tmp6_);
#line 162 "values.c"
}

LiveChartBounds*
live_chart_values_get_bounds (LiveChartValues* self)
{
	LiveChartBounds* result;
	LiveChartBounds* _tmp0_;
#line 12 "../src/values.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 12 "../src/values.vala"
	_tmp0_ = self->priv->_bounds;
#line 12 "../src/values.vala"
	result = _tmp0_;
#line 12 "../src/values.vala"
	return result;
#line 178 "values.c"
}

static gpointer
_g_object_ref0 (gpointer self)
{
#line 12 "../src/values.vala"
	return self ? g_object_ref (self) : NULL;
#line 186 "values.c"
}

void
live_chart_values_set_bounds (LiveChartValues* self,
                              LiveChartBounds* value)
{
	LiveChartBounds* old_value;
#line 12 "../src/values.vala"
	g_return_if_fail (self != NULL);
#line 12 "../src/values.vala"
	old_value = live_chart_values_get_bounds (self);
#line 12 "../src/values.vala"
	if (old_value != value) {
#line 200 "values.c"
		LiveChartBounds* _tmp0_;
#line 12 "../src/values.vala"
		_tmp0_ = _g_object_ref0 (value);
#line 12 "../src/values.vala"
		_g_object_unref0 (self->priv->_bounds);
#line 12 "../src/values.vala"
		self->priv->_bounds = _tmp0_;
#line 12 "../src/values.vala"
		g_object_notify_by_pspec ((GObject *) self, live_chart_values_properties[LIVE_CHART_VALUES_BOUNDS_PROPERTY]);
#line 210 "values.c"
	}
}

static void
live_chart_values_class_init (LiveChartValuesClass * klass,
                              gpointer klass_data)
{
#line 9 "../src/values.vala"
	live_chart_values_parent_class = g_type_class_peek_parent (klass);
#line 9 "../src/values.vala"
	g_type_class_adjust_private_offset (klass, &LiveChartValues_private_offset);
#line 9 "../src/values.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_live_chart_values_get_property;
#line 9 "../src/values.vala"
	G_OBJECT_CLASS (klass)->set_property = _vala_live_chart_values_set_property;
#line 9 "../src/values.vala"
	G_OBJECT_CLASS (klass)->finalize = live_chart_values_finalize;
#line 9 "../src/values.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), LIVE_CHART_VALUES_BOUNDS_PROPERTY, live_chart_values_properties[LIVE_CHART_VALUES_BOUNDS_PROPERTY] = g_param_spec_object ("bounds", "bounds", "bounds", LIVE_CHART_TYPE_BOUNDS, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
#line 230 "values.c"
}

static void
live_chart_values_instance_init (LiveChartValues * self,
                                 gpointer klass)
{
#line 9 "../src/values.vala"
	self->priv = live_chart_values_get_instance_private (self);
#line 239 "values.c"
}

static void
live_chart_values_finalize (GObject * obj)
{
	LiveChartValues * self;
#line 9 "../src/values.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, LIVE_CHART_TYPE_VALUES, LiveChartValues);
#line 11 "../src/values.vala"
	_g_object_unref0 (self->priv->_bounds);
#line 9 "../src/values.vala"
	G_OBJECT_CLASS (live_chart_values_parent_class)->finalize (obj);
#line 252 "values.c"
}

static GType
live_chart_values_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (LiveChartValuesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) live_chart_values_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LiveChartValues), 0, (GInstanceInitFunc) live_chart_values_instance_init, NULL };
	GType live_chart_values_type_id;
	live_chart_values_type_id = g_type_register_static (GEE_TYPE_LINKED_LIST, "LiveChartValues", &g_define_type_info, 0);
	LiveChartValues_private_offset = g_type_add_instance_private (live_chart_values_type_id, sizeof (LiveChartValuesPrivate));
	return live_chart_values_type_id;
}

GType
live_chart_values_get_type (void)
{
	static volatile gsize live_chart_values_type_id__once = 0;
	if (g_once_init_enter (&live_chart_values_type_id__once)) {
		GType live_chart_values_type_id;
		live_chart_values_type_id = live_chart_values_get_type_once ();
		g_once_init_leave (&live_chart_values_type_id__once, live_chart_values_type_id);
	}
	return live_chart_values_type_id__once;
}

static void
_vala_live_chart_values_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	LiveChartValues * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, LIVE_CHART_TYPE_VALUES, LiveChartValues);
#line 9 "../src/values.vala"
	switch (property_id) {
#line 9 "../src/values.vala"
		case LIVE_CHART_VALUES_BOUNDS_PROPERTY:
#line 9 "../src/values.vala"
		g_value_set_object (value, live_chart_values_get_bounds (self));
#line 9 "../src/values.vala"
		break;
#line 293 "values.c"
		default:
#line 9 "../src/values.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 9 "../src/values.vala"
		break;
#line 299 "values.c"
	}
}

static void
_vala_live_chart_values_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	LiveChartValues * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, LIVE_CHART_TYPE_VALUES, LiveChartValues);
#line 9 "../src/values.vala"
	switch (property_id) {
#line 9 "../src/values.vala"
		case LIVE_CHART_VALUES_BOUNDS_PROPERTY:
#line 9 "../src/values.vala"
		live_chart_values_set_bounds (self, g_value_get_object (value));
#line 9 "../src/values.vala"
		break;
#line 319 "values.c"
		default:
#line 9 "../src/values.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 9 "../src/values.vala"
		break;
#line 325 "values.c"
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

