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

/*
* Copyright © 2025 Alain M. (https://github.com/alainm23/planify)
*
* 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
*
* Authored by: Alain M. <alainmh23@gmail.com>
*/

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

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	OBJECTS_TRANSLATION_METRIC_0_PROPERTY,
	OBJECTS_TRANSLATION_METRIC_CODE_PROPERTY,
	OBJECTS_TRANSLATION_METRIC_LANGUAGE_PROPERTY,
	OBJECTS_TRANSLATION_METRIC_TOTAL_STRINGS_PROPERTY,
	OBJECTS_TRANSLATION_METRIC_TRANSLATED_STRINGS_PROPERTY,
	OBJECTS_TRANSLATION_METRIC_TRANSLATED_PERCENT_PROPERTY,
	OBJECTS_TRANSLATION_METRIC_NUM_PROPERTIES
};
static GParamSpec* objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ObjectsTranslationMetricPrivate {
	gchar* _code;
	gchar* _language;
	gint _total_strings;
	gint _translated_strings;
	gdouble _translated_percent;
};

static gint ObjectsTranslationMetric_private_offset;
static gpointer objects_translation_metric_parent_class = NULL;

static void objects_translation_metric_finalize (GObject * obj);
static GType objects_translation_metric_get_type_once (void);
static void _vala_objects_translation_metric_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_objects_translation_metric_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
objects_translation_metric_get_instance_private (ObjectsTranslationMetric* self)
{
	return G_STRUCT_MEMBER_P (self, ObjectsTranslationMetric_private_offset);
}

ObjectsTranslationMetric*
objects_translation_metric_construct (GType object_type)
{
	ObjectsTranslationMetric * self = NULL;
	self = (ObjectsTranslationMetric*) g_object_new (object_type, NULL);
	return self;
}

ObjectsTranslationMetric*
objects_translation_metric_new (void)
{
	return objects_translation_metric_construct (OBJECTS_TYPE_TRANSLATION_METRIC);
}

const gchar*
objects_translation_metric_get_code (ObjectsTranslationMetric* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_code;
	result = _tmp0_;
	return result;
}

void
objects_translation_metric_set_code (ObjectsTranslationMetric* self,
                                     const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_translation_metric_get_code (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_code);
		self->priv->_code = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_CODE_PROPERTY]);
	}
}

const gchar*
objects_translation_metric_get_language (ObjectsTranslationMetric* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_language;
	result = _tmp0_;
	return result;
}

void
objects_translation_metric_set_language (ObjectsTranslationMetric* self,
                                         const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_translation_metric_get_language (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_language);
		self->priv->_language = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_LANGUAGE_PROPERTY]);
	}
}

gint
objects_translation_metric_get_total_strings (ObjectsTranslationMetric* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_total_strings;
	return result;
}

void
objects_translation_metric_set_total_strings (ObjectsTranslationMetric* self,
                                              gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_translation_metric_get_total_strings (self);
	if (old_value != value) {
		self->priv->_total_strings = value;
		g_object_notify_by_pspec ((GObject *) self, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_TOTAL_STRINGS_PROPERTY]);
	}
}

gint
objects_translation_metric_get_translated_strings (ObjectsTranslationMetric* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_translated_strings;
	return result;
}

void
objects_translation_metric_set_translated_strings (ObjectsTranslationMetric* self,
                                                   gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_translation_metric_get_translated_strings (self);
	if (old_value != value) {
		self->priv->_translated_strings = value;
		g_object_notify_by_pspec ((GObject *) self, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_TRANSLATED_STRINGS_PROPERTY]);
	}
}

gdouble
objects_translation_metric_get_translated_percent (ObjectsTranslationMetric* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->_translated_percent;
	return result;
}

void
objects_translation_metric_set_translated_percent (ObjectsTranslationMetric* self,
                                                   gdouble value)
{
	gdouble old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_translation_metric_get_translated_percent (self);
	if (old_value != value) {
		self->priv->_translated_percent = value;
		g_object_notify_by_pspec ((GObject *) self, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_TRANSLATED_PERCENT_PROPERTY]);
	}
}

static void
objects_translation_metric_class_init (ObjectsTranslationMetricClass * klass,
                                       gpointer klass_data)
{
	objects_translation_metric_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ObjectsTranslationMetric_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_objects_translation_metric_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_objects_translation_metric_set_property;
	G_OBJECT_CLASS (klass)->finalize = objects_translation_metric_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_TRANSLATION_METRIC_CODE_PROPERTY, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_CODE_PROPERTY] = g_param_spec_string ("code", "code", "code", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_TRANSLATION_METRIC_LANGUAGE_PROPERTY, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_LANGUAGE_PROPERTY] = g_param_spec_string ("language", "language", "language", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_TRANSLATION_METRIC_TOTAL_STRINGS_PROPERTY, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_TOTAL_STRINGS_PROPERTY] = g_param_spec_int ("total-strings", "total-strings", "total-strings", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_TRANSLATION_METRIC_TRANSLATED_STRINGS_PROPERTY, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_TRANSLATED_STRINGS_PROPERTY] = g_param_spec_int ("translated-strings", "translated-strings", "translated-strings", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_TRANSLATION_METRIC_TRANSLATED_PERCENT_PROPERTY, objects_translation_metric_properties[OBJECTS_TRANSLATION_METRIC_TRANSLATED_PERCENT_PROPERTY] = g_param_spec_double ("translated-percent", "translated-percent", "translated-percent", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
objects_translation_metric_instance_init (ObjectsTranslationMetric * self,
                                          gpointer klass)
{
	self->priv = objects_translation_metric_get_instance_private (self);
}

static void
objects_translation_metric_finalize (GObject * obj)
{
	ObjectsTranslationMetric * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OBJECTS_TYPE_TRANSLATION_METRIC, ObjectsTranslationMetric);
	_g_free0 (self->priv->_code);
	_g_free0 (self->priv->_language);
	G_OBJECT_CLASS (objects_translation_metric_parent_class)->finalize (obj);
}

static GType
objects_translation_metric_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ObjectsTranslationMetricClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) objects_translation_metric_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ObjectsTranslationMetric), 0, (GInstanceInitFunc) objects_translation_metric_instance_init, NULL };
	GType objects_translation_metric_type_id;
	objects_translation_metric_type_id = g_type_register_static (G_TYPE_OBJECT, "ObjectsTranslationMetric", &g_define_type_info, 0);
	ObjectsTranslationMetric_private_offset = g_type_add_instance_private (objects_translation_metric_type_id, sizeof (ObjectsTranslationMetricPrivate));
	return objects_translation_metric_type_id;
}

GType
objects_translation_metric_get_type (void)
{
	static volatile gsize objects_translation_metric_type_id__once = 0;
	if (g_once_init_enter (&objects_translation_metric_type_id__once)) {
		GType objects_translation_metric_type_id;
		objects_translation_metric_type_id = objects_translation_metric_get_type_once ();
		g_once_init_leave (&objects_translation_metric_type_id__once, objects_translation_metric_type_id);
	}
	return objects_translation_metric_type_id__once;
}

static void
_vala_objects_translation_metric_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	ObjectsTranslationMetric * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_TYPE_TRANSLATION_METRIC, ObjectsTranslationMetric);
	switch (property_id) {
		case OBJECTS_TRANSLATION_METRIC_CODE_PROPERTY:
		g_value_set_string (value, objects_translation_metric_get_code (self));
		break;
		case OBJECTS_TRANSLATION_METRIC_LANGUAGE_PROPERTY:
		g_value_set_string (value, objects_translation_metric_get_language (self));
		break;
		case OBJECTS_TRANSLATION_METRIC_TOTAL_STRINGS_PROPERTY:
		g_value_set_int (value, objects_translation_metric_get_total_strings (self));
		break;
		case OBJECTS_TRANSLATION_METRIC_TRANSLATED_STRINGS_PROPERTY:
		g_value_set_int (value, objects_translation_metric_get_translated_strings (self));
		break;
		case OBJECTS_TRANSLATION_METRIC_TRANSLATED_PERCENT_PROPERTY:
		g_value_set_double (value, objects_translation_metric_get_translated_percent (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_objects_translation_metric_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	ObjectsTranslationMetric * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_TYPE_TRANSLATION_METRIC, ObjectsTranslationMetric);
	switch (property_id) {
		case OBJECTS_TRANSLATION_METRIC_CODE_PROPERTY:
		objects_translation_metric_set_code (self, g_value_get_string (value));
		break;
		case OBJECTS_TRANSLATION_METRIC_LANGUAGE_PROPERTY:
		objects_translation_metric_set_language (self, g_value_get_string (value));
		break;
		case OBJECTS_TRANSLATION_METRIC_TOTAL_STRINGS_PROPERTY:
		objects_translation_metric_set_total_strings (self, g_value_get_int (value));
		break;
		case OBJECTS_TRANSLATION_METRIC_TRANSLATED_STRINGS_PROPERTY:
		objects_translation_metric_set_translated_strings (self, g_value_get_int (value));
		break;
		case OBJECTS_TRANSLATION_METRIC_TRANSLATED_PERCENT_PROPERTY:
		objects_translation_metric_set_translated_percent (self, g_value_get_double (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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;
}

