/* plugin-register.c generated by valac 0.36.12.13-3ae08, the Vala compiler
 * generated from plugin-register.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

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


#define GAMES_TYPE_PLUGIN_REGISTER (games_plugin_register_get_type ())
#define GAMES_PLUGIN_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegister))
#define GAMES_PLUGIN_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegisterClass))
#define GAMES_IS_PLUGIN_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLUGIN_REGISTER))
#define GAMES_IS_PLUGIN_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLUGIN_REGISTER))
#define GAMES_PLUGIN_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegisterClass))

typedef struct _GamesPluginRegister GamesPluginRegister;
typedef struct _GamesPluginRegisterClass GamesPluginRegisterClass;
typedef struct _GamesPluginRegisterPrivate GamesPluginRegisterPrivate;

#define GAMES_TYPE_PLUGIN_REGISTRAR (games_plugin_registrar_get_type ())
#define GAMES_PLUGIN_REGISTRAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLUGIN_REGISTRAR, GamesPluginRegistrar))
#define GAMES_PLUGIN_REGISTRAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLUGIN_REGISTRAR, GamesPluginRegistrarClass))
#define GAMES_IS_PLUGIN_REGISTRAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLUGIN_REGISTRAR))
#define GAMES_IS_PLUGIN_REGISTRAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLUGIN_REGISTRAR))
#define GAMES_PLUGIN_REGISTRAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLUGIN_REGISTRAR, GamesPluginRegistrarClass))

typedef struct _GamesPluginRegistrar GamesPluginRegistrar;
typedef struct _GamesPluginRegistrarClass GamesPluginRegistrarClass;
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GAMES_TYPE_PLUGIN_REGISTER_ITERATOR (games_plugin_register_iterator_get_type ())
#define GAMES_PLUGIN_REGISTER_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR, GamesPluginRegisterIterator))
#define GAMES_PLUGIN_REGISTER_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR, GamesPluginRegisterIteratorClass))
#define GAMES_IS_PLUGIN_REGISTER_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR))
#define GAMES_IS_PLUGIN_REGISTER_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR))
#define GAMES_PLUGIN_REGISTER_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR, GamesPluginRegisterIteratorClass))

typedef struct _GamesPluginRegisterIterator GamesPluginRegisterIterator;
typedef struct _GamesPluginRegisterIteratorClass GamesPluginRegisterIteratorClass;

struct _GamesPluginRegister {
	GObject parent_instance;
	GamesPluginRegisterPrivate * priv;
};

struct _GamesPluginRegisterClass {
	GObjectClass parent_class;
};

struct _GamesPluginRegisterPrivate {
	GHashTable* plugin_registrars;
};

typedef enum  {
	GAMES_PLUGIN_ERROR_INVALID_PLUGIN_DESCRIPTOR,
	GAMES_PLUGIN_ERROR_NOT_A_PLUGIN
} GamesPluginError;
#define GAMES_PLUGIN_ERROR games_plugin_error_quark ()
typedef void (*GamesPluginRegisterPluginRegistrarFunc) (GamesPluginRegistrar* plugin_registrar, void* user_data);

static gpointer games_plugin_register_parent_class = NULL;
static GamesPluginRegister* games_plugin_register_instance;
static GamesPluginRegister* games_plugin_register_instance = NULL;

GType games_plugin_register_get_type (void) G_GNUC_CONST;
GType games_plugin_registrar_get_type (void) G_GNUC_CONST;
#define GAMES_PLUGIN_REGISTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegisterPrivate))
enum  {
	GAMES_PLUGIN_REGISTER_0_PROPERTY
};
static GamesPluginRegister* games_plugin_register_new (void);
static GamesPluginRegister* games_plugin_register_construct (GType object_type);
static void _g_free0_ (gpointer var);
static void _g_object_unref0_ (gpointer var);
GamesPluginRegister* games_plugin_register_get_register (void);
gpointer games_plugin_register_iterator_ref (gpointer instance);
void games_plugin_register_iterator_unref (gpointer instance);
GParamSpec* games_param_spec_plugin_register_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void games_value_set_plugin_register_iterator (GValue* value, gpointer v_object);
void games_value_take_plugin_register_iterator (GValue* value, gpointer v_object);
gpointer games_value_get_plugin_register_iterator (const GValue* value);
GType games_plugin_register_iterator_get_type (void) G_GNUC_CONST;
GamesPluginRegisterIterator* games_plugin_register_iterator (GamesPluginRegister* self);
GamesPluginRegisterIterator* games_plugin_register_iterator_new (GamesPluginRegister* plugin_register);
GamesPluginRegisterIterator* games_plugin_register_iterator_construct (GType object_type, GamesPluginRegister* plugin_register);
GamesPluginRegistrar* games_plugin_register_get_plugin_registrar (GamesPluginRegister* self, const gchar* descriptor_filename, GError** error);
GQuark games_plugin_error_quark (void);
GamesPluginRegistrar* games_plugin_registrar_new (const gchar* plugin_filename, GError** error);
GamesPluginRegistrar* games_plugin_registrar_construct (GType object_type, const gchar* plugin_filename, GError** error);
static void games_plugin_register_finalize (GObject * obj);


static void _g_free0_ (gpointer var) {
	var = (g_free (var), NULL);
}


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static GamesPluginRegister* games_plugin_register_construct (GType object_type) {
	GamesPluginRegister * self = NULL;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	self = (GamesPluginRegister*) g_object_new (object_type, NULL);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->plugin_registrars);
	self->priv->plugin_registrars = _tmp2_;
	return self;
}


static GamesPluginRegister* games_plugin_register_new (void) {
	return games_plugin_register_construct (GAMES_TYPE_PLUGIN_REGISTER);
}


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


GamesPluginRegister* games_plugin_register_get_register (void) {
	GamesPluginRegister* result = NULL;
	GamesPluginRegister* _tmp0_;
	GamesPluginRegister* _tmp2_;
	GamesPluginRegister* _tmp3_;
	_tmp0_ = games_plugin_register_instance;
	if (_tmp0_ == NULL) {
		GamesPluginRegister* _tmp1_;
		_tmp1_ = games_plugin_register_new ();
		_g_object_unref0 (games_plugin_register_instance);
		games_plugin_register_instance = _tmp1_;
	}
	_tmp2_ = games_plugin_register_instance;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}


GamesPluginRegisterIterator* games_plugin_register_iterator (GamesPluginRegister* self) {
	GamesPluginRegisterIterator* result = NULL;
	GamesPluginRegisterIterator* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = games_plugin_register_iterator_new (self);
	result = _tmp0_;
	return result;
}


GamesPluginRegistrar* games_plugin_register_get_plugin_registrar (GamesPluginRegister* self, const gchar* descriptor_filename, GError** error) {
	GamesPluginRegistrar* result = NULL;
	GHashTable* _tmp0_;
	const gchar* _tmp1_;
	gboolean _tmp2_;
	GamesPluginRegistrar* registrar = NULL;
	const gchar* _tmp7_;
	GamesPluginRegistrar* _tmp8_;
	GHashTable* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	GamesPluginRegistrar* _tmp12_;
	GamesPluginRegistrar* _tmp13_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (descriptor_filename != NULL, NULL);
	_tmp0_ = self->priv->plugin_registrars;
	_tmp1_ = descriptor_filename;
	_tmp2_ = g_hash_table_contains (_tmp0_, _tmp1_);
	if (_tmp2_) {
		GHashTable* _tmp3_;
		const gchar* _tmp4_;
		gconstpointer _tmp5_;
		GamesPluginRegistrar* _tmp6_;
		_tmp3_ = self->priv->plugin_registrars;
		_tmp4_ = descriptor_filename;
		_tmp5_ = g_hash_table_lookup (_tmp3_, _tmp4_);
		_tmp6_ = _g_object_ref0 ((GamesPluginRegistrar*) _tmp5_);
		result = _tmp6_;
		return result;
	}
	_tmp7_ = descriptor_filename;
	_tmp8_ = games_plugin_registrar_new (_tmp7_, &_inner_error_);
	registrar = _tmp8_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp9_ = self->priv->plugin_registrars;
	_tmp10_ = descriptor_filename;
	_tmp11_ = g_strdup (_tmp10_);
	_tmp12_ = registrar;
	_tmp13_ = _g_object_ref0 (_tmp12_);
	g_hash_table_insert (_tmp9_, _tmp11_, _tmp13_);
	result = registrar;
	return result;
}


static void games_plugin_register_class_init (GamesPluginRegisterClass * klass) {
	games_plugin_register_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesPluginRegisterPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_plugin_register_finalize;
}


static void games_plugin_register_instance_init (GamesPluginRegister * self) {
	self->priv = GAMES_PLUGIN_REGISTER_GET_PRIVATE (self);
}


static void games_plugin_register_finalize (GObject * obj) {
	GamesPluginRegister * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegister);
	_g_hash_table_unref0 (self->priv->plugin_registrars);
	G_OBJECT_CLASS (games_plugin_register_parent_class)->finalize (obj);
}


GType games_plugin_register_get_type (void) {
	static volatile gsize games_plugin_register_type_id__volatile = 0;
	if (g_once_init_enter (&games_plugin_register_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesPluginRegisterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_plugin_register_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesPluginRegister), 0, (GInstanceInitFunc) games_plugin_register_instance_init, NULL };
		GType games_plugin_register_type_id;
		games_plugin_register_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesPluginRegister", &g_define_type_info, 0);
		g_once_init_leave (&games_plugin_register_type_id__volatile, games_plugin_register_type_id);
	}
	return games_plugin_register_type_id__volatile;
}



