/* vala-dmap-db.c generated by valac 0.56.17, the Vala compiler
 * generated from vala-dmap-db.vala, do not modify */

/*   FILE: vala-dmap-db.vala -- A DmapDb implementation in Vala
 * AUTHOR: W. Michael Petullo <mike@flyn.org>
 *   DATE: 21 December 2010 
 *
 * Copyright (c) 2010 W. Michael Petullo <new@flyn.org>
 * All rights reserved.
 *
 * 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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <glib-object.h>
#include <libdmapsharing/dmap.h>
#include <gee.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_VALA_DMAP_DB (vala_dmap_db_get_type ())
#define VALA_DMAP_DB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_VALA_DMAP_DB, ValaDmapDb))
#define VALA_DMAP_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_VALA_DMAP_DB, ValaDmapDbClass))
#define IS_VALA_DMAP_DB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_VALA_DMAP_DB))
#define IS_VALA_DMAP_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_VALA_DMAP_DB))
#define VALA_DMAP_DB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_VALA_DMAP_DB, ValaDmapDbClass))

typedef struct _ValaDmapDb ValaDmapDb;
typedef struct _ValaDmapDbClass ValaDmapDbClass;
typedef struct _ValaDmapDbPrivate ValaDmapDbPrivate;
enum  {
	VALA_DMAP_DB_0_PROPERTY,
	VALA_DMAP_DB_NUM_PROPERTIES
};
static GParamSpec* vala_dmap_db_properties[VALA_DMAP_DB_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ValaDmapDb {
	GObject parent_instance;
	ValaDmapDbPrivate * priv;
};

struct _ValaDmapDbClass {
	GObjectClass parent_class;
};

struct _ValaDmapDbPrivate {
	GeeArrayList* db;
};

static gint ValaDmapDb_private_offset;
static gpointer vala_dmap_db_parent_class = NULL;
static DmapDbInterface * vala_dmap_db_dmap_db_parent_iface = NULL;

VALA_EXTERN GType vala_dmap_db_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ValaDmapDb, g_object_unref)
static guint vala_dmap_db_real_add (DmapDb* base,
                             DmapRecord* record,
                             GError** error);
static guint vala_dmap_db_real_add_path (DmapDb* base,
                                  const gchar* path,
                                  GError** error);
static guint vala_dmap_db_real_add_with_id (DmapDb* base,
                                     DmapRecord* record,
                                     guint id,
                                     GError** error);
static gint64 vala_dmap_db_real_count (DmapDb* base);
static void vala_dmap_db_real_foreach (DmapDb* base,
                                DmapIdRecordFunc func,
                                gpointer func_target);
static DmapRecord* vala_dmap_db_real_lookup_by_id (DmapDb* base,
                                            guint id);
static guint vala_dmap_db_real_lookup_id_by_location (DmapDb* base,
                                               const gchar* location);
VALA_EXTERN ValaDmapDb* vala_dmap_db_new (void);
VALA_EXTERN ValaDmapDb* vala_dmap_db_construct (GType object_type);
static void vala_dmap_db_finalize (GObject * obj);
static GType vala_dmap_db_get_type_once (void);

static inline gpointer
vala_dmap_db_get_instance_private (ValaDmapDb* self)
{
	return G_STRUCT_MEMBER_P (self, ValaDmapDb_private_offset);
}

static guint
vala_dmap_db_real_add (DmapDb* base,
                       DmapRecord* record,
                       GError** error)
{
	ValaDmapDb * self;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	guint result;
	self = (ValaDmapDb*) base;
	g_return_val_if_fail (record != NULL, 0U);
	_tmp0_ = self->priv->db;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, G_TYPE_CHECK_INSTANCE_CAST (record, dmap_record_get_type (), DmapRecord));
	_tmp1_ = self->priv->db;
	_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	result = (guint) _tmp3_;
	return result;
}

static guint
vala_dmap_db_real_add_path (DmapDb* base,
                            const gchar* path,
                            GError** error)
{
	ValaDmapDb * self;
	self = (ValaDmapDb*) base;
	g_return_val_if_fail (path != NULL, 0U);
	g_error ("vala-dmap-db.vala:35: add_path not implemented");
}

static guint
vala_dmap_db_real_add_with_id (DmapDb* base,
                               DmapRecord* record,
                               guint id,
                               GError** error)
{
	ValaDmapDb * self;
	self = (ValaDmapDb*) base;
	g_return_val_if_fail (record != NULL, 0U);
	g_error ("vala-dmap-db.vala:39: add_with_id not implemented");
}

static gint64
vala_dmap_db_real_count (DmapDb* base)
{
	ValaDmapDb * self;
	GeeArrayList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint64 result;
	self = (ValaDmapDb*) base;
	_tmp0_ = self->priv->db;
	_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = (gint64) _tmp2_;
	return result;
}

static void
vala_dmap_db_real_foreach (DmapDb* base,
                           DmapIdRecordFunc func,
                           gpointer func_target)
{
	ValaDmapDb * self;
	gint i = 0;
	self = (ValaDmapDb*) base;
	{
		gboolean _tmp0_ = FALSE;
		i = 0;
		_tmp0_ = TRUE;
		while (TRUE) {
			GeeArrayList* _tmp2_;
			gint _tmp3_;
			gint _tmp4_;
			GeeArrayList* _tmp5_;
			gpointer _tmp6_;
			if (!_tmp0_) {
				gint _tmp1_;
				_tmp1_ = i;
				i = _tmp1_ + 1;
			}
			_tmp0_ = FALSE;
			_tmp2_ = self->priv->db;
			_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
			_tmp4_ = _tmp3_;
			if (!(i < _tmp4_)) {
				break;
			}
			_tmp5_ = self->priv->db;
			_tmp6_ = gee_abstract_list_get ((GeeAbstractList*) _tmp5_, i);
			func ((guint) (i + 1), (DmapRecord*) _tmp6_, func_target);
		}
	}
}

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

static DmapRecord*
vala_dmap_db_real_lookup_by_id (DmapDb* base,
                                guint id)
{
	ValaDmapDb * self;
	DmapRecord* record = NULL;
	GeeArrayList* _tmp0_;
	gpointer _tmp1_;
	DmapRecord* _tmp2_;
	DmapRecord* result;
	self = (ValaDmapDb*) base;
	_tmp0_ = self->priv->db;
	_tmp1_ = gee_abstract_list_get ((GeeAbstractList*) _tmp0_, ((gint) id) - 1);
	record = (DmapRecord*) _tmp1_;
	g_object_ref ((GObject*) record);
	_tmp2_ = _g_object_ref0 (record);
	result = _tmp2_;
	return result;
}

static guint
vala_dmap_db_real_lookup_id_by_location (DmapDb* base,
                                         const gchar* location)
{
	ValaDmapDb * self;
	self = (ValaDmapDb*) base;
	g_return_val_if_fail (location != NULL, 0U);
	g_error ("vala-dmap-db.vala:65: lookup_id_by_location not implemented");
}

ValaDmapDb*
vala_dmap_db_construct (GType object_type)
{
	ValaDmapDb * self = NULL;
	self = (ValaDmapDb*) g_object_new (object_type, NULL);
	return self;
}

ValaDmapDb*
vala_dmap_db_new (void)
{
	return vala_dmap_db_construct (TYPE_VALA_DMAP_DB);
}

static void
vala_dmap_db_class_init (ValaDmapDbClass * klass,
                         gpointer klass_data)
{
	vala_dmap_db_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ValaDmapDb_private_offset);
	G_OBJECT_CLASS (klass)->finalize = vala_dmap_db_finalize;
}

static void
vala_dmap_db_dmap_db_interface_init (DmapDbInterface * iface,
                                     gpointer iface_data)
{
	vala_dmap_db_dmap_db_parent_iface = g_type_interface_peek_parent (iface);
	iface->add = (guint (*) (DmapDb*, DmapRecord*, GError**)) vala_dmap_db_real_add;
	iface->add_path = (guint (*) (DmapDb*, const gchar*, GError**)) vala_dmap_db_real_add_path;
	iface->add_with_id = (guint (*) (DmapDb*, DmapRecord*, guint, GError**)) vala_dmap_db_real_add_with_id;
	iface->count = (gint64 (*) (DmapDb*)) vala_dmap_db_real_count;
	iface->foreach = (void (*) (DmapDb*, DmapIdRecordFunc, gpointer)) vala_dmap_db_real_foreach;
	iface->lookup_by_id = (DmapRecord* (*) (DmapDb*, guint)) vala_dmap_db_real_lookup_by_id;
	iface->lookup_id_by_location = (guint (*) (DmapDb*, const gchar*)) vala_dmap_db_real_lookup_id_by_location;
}

static void
vala_dmap_db_instance_init (ValaDmapDb * self,
                            gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = vala_dmap_db_get_instance_private (self);
	_tmp0_ = gee_array_list_new (dmap_record_get_type (), NULL, NULL, NULL, NULL, NULL);
	self->priv->db = _tmp0_;
}

static void
vala_dmap_db_finalize (GObject * obj)
{
	ValaDmapDb * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_VALA_DMAP_DB, ValaDmapDb);
	_g_object_unref0 (self->priv->db);
	G_OBJECT_CLASS (vala_dmap_db_parent_class)->finalize (obj);
}

static GType
vala_dmap_db_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValaDmapDbClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_dmap_db_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaDmapDb), 0, (GInstanceInitFunc) vala_dmap_db_instance_init, NULL };
	static const GInterfaceInfo dmap_db_info = { (GInterfaceInitFunc) vala_dmap_db_dmap_db_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType vala_dmap_db_type_id;
	vala_dmap_db_type_id = g_type_register_static (G_TYPE_OBJECT, "ValaDmapDb", &g_define_type_info, 0);
	g_type_add_interface_static (vala_dmap_db_type_id, dmap_db_get_type (), &dmap_db_info);
	ValaDmapDb_private_offset = g_type_add_instance_private (vala_dmap_db_type_id, sizeof (ValaDmapDbPrivate));
	return vala_dmap_db_type_id;
}

GType
vala_dmap_db_get_type (void)
{
	static volatile gsize vala_dmap_db_type_id__once = 0;
	if (g_once_init_enter (&vala_dmap_db_type_id__once)) {
		GType vala_dmap_db_type_id;
		vala_dmap_db_type_id = vala_dmap_db_get_type_once ();
		g_once_init_leave (&vala_dmap_db_type_id__once, vala_dmap_db_type_id);
	}
	return vala_dmap_db_type_id__once;
}

