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

/*
 * Copyright (C) 2012-2014 Daiki Ueno <ueno@gnu.org>
 * Copyright (C) 2012-2014 Red Hat, Inc.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

#include "libkkc/libkkc.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  {
	KKC_DECODER_0_PROPERTY,
	KKC_DECODER_NUM_PROPERTIES
};
static GParamSpec* kkc_decoder_properties[KKC_DECODER_NUM_PROPERTIES];

static gpointer kkc_decoder_parent_class = NULL;

static KkcSegment** kkc_decoder_real_decode (KkcDecoder* self,
                                      const gchar* input,
                                      gint nbest,
                                      gint* constraint,
                                      gint constraint_length1,
                                      gint* result_length1);
static KkcSegment** kkc_decoder_real_decode_with_costs (KkcDecoder* self,
                                                 const gchar* input,
                                                 gint nbest,
                                                 gint* constraint,
                                                 gint constraint_length1,
                                                 gdouble max_distance,
                                                 gdouble min_path_cost,
                                                 gint* result_length1);
static GType kkc_decoder_get_type_once (void);

static KkcSegment**
kkc_decoder_real_decode (KkcDecoder* self,
                         const gchar* input,
                         gint nbest,
                         gint* constraint,
                         gint constraint_length1,
                         gint* result_length1)
{
	g_critical ("Type `%s' does not implement abstract method `kkc_decoder_decode'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

KkcSegment**
kkc_decoder_decode (KkcDecoder* self,
                    const gchar* input,
                    gint nbest,
                    gint* constraint,
                    gint constraint_length1,
                    gint* result_length1)
{
	KkcDecoderClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = KKC_DECODER_GET_CLASS (self);
	if (_klass_->decode) {
		return _klass_->decode (self, input, nbest, constraint, constraint_length1, result_length1);
	}
	return NULL;
}

static KkcSegment**
kkc_decoder_real_decode_with_costs (KkcDecoder* self,
                                    const gchar* input,
                                    gint nbest,
                                    gint* constraint,
                                    gint constraint_length1,
                                    gdouble max_distance,
                                    gdouble min_path_cost,
                                    gint* result_length1)
{
	g_critical ("Type `%s' does not implement abstract method `kkc_decoder_decode_with_costs'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

KkcSegment**
kkc_decoder_decode_with_costs (KkcDecoder* self,
                               const gchar* input,
                               gint nbest,
                               gint* constraint,
                               gint constraint_length1,
                               gdouble max_distance,
                               gdouble min_path_cost,
                               gint* result_length1)
{
	KkcDecoderClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = KKC_DECODER_GET_CLASS (self);
	if (_klass_->decode_with_costs) {
		return _klass_->decode_with_costs (self, input, nbest, constraint, constraint_length1, max_distance, min_path_cost, result_length1);
	}
	return NULL;
}

KkcDecoder*
kkc_decoder_create (KkcLanguageModel* model)
{
	KkcDecoder* result;
	g_return_val_if_fail (model != NULL, NULL);
	if (KKC_IS_TRIGRAM_LANGUAGE_MODEL (model)) {
		KkcTrigramDecoder* _tmp0_;
		_tmp0_ = kkc_trigram_decoder_new (KKC_IS_TRIGRAM_LANGUAGE_MODEL (model) ? ((KkcTrigramLanguageModel*) model) : NULL);
		result = (KkcDecoder*) _tmp0_;
		return result;
	} else {
		if (KKC_IS_BIGRAM_LANGUAGE_MODEL (model)) {
			KkcBigramDecoder* _tmp1_;
			_tmp1_ = kkc_bigram_decoder_new (KKC_IS_BIGRAM_LANGUAGE_MODEL (model) ? ((KkcBigramLanguageModel*) model) : NULL);
			result = (KkcDecoder*) _tmp1_;
			return result;
		} else {
			g_assert_not_reached ();
		}
	}
}

KkcDecoder*
kkc_decoder_construct (GType object_type)
{
	KkcDecoder * self = NULL;
	self = (KkcDecoder*) g_object_new (object_type, NULL);
	return self;
}

static void
kkc_decoder_class_init (KkcDecoderClass * klass,
                        gpointer klass_data)
{
	kkc_decoder_parent_class = g_type_class_peek_parent (klass);
	((KkcDecoderClass *) klass)->decode = (KkcSegment** (*) (KkcDecoder*, const gchar*, gint, gint*, gint, gint*)) kkc_decoder_real_decode;
	((KkcDecoderClass *) klass)->decode_with_costs = (KkcSegment** (*) (KkcDecoder*, const gchar*, gint, gint*, gint, gdouble, gdouble, gint*)) kkc_decoder_real_decode_with_costs;
}

static void
kkc_decoder_instance_init (KkcDecoder * self,
                           gpointer klass)
{
}

static GType
kkc_decoder_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcDecoderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_decoder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcDecoder), 0, (GInstanceInitFunc) kkc_decoder_instance_init, NULL };
	GType kkc_decoder_type_id;
	kkc_decoder_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcDecoder", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return kkc_decoder_type_id;
}

GType
kkc_decoder_get_type (void)
{
	static volatile gsize kkc_decoder_type_id__once = 0;
	if (g_once_init_enter (&kkc_decoder_type_id__once)) {
		GType kkc_decoder_type_id;
		kkc_decoder_type_id = kkc_decoder_get_type_once ();
		g_once_init_leave (&kkc_decoder_type_id__once, kkc_decoder_type_id);
	}
	return kkc_decoder_type_id__once;
}

