/* rygel-lms-plugin-factory.c generated by valac 0.31.1.6-4f062, the Vala compiler
 * generated from rygel-lms-plugin-factory.vala, do not modify */

/*
 * Copyright (C) 2013 Intel Corporation.
 *
 * Author: Jussi Kukkonen <jussi.kukkonen@intel.com>
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Rygel 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser 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.
 */

#include <glib.h>
#include <glib-object.h>
#include <rygel-core.h>
#include <rygel-server.h>
#include <gobject/gvaluecollector.h>


#define RYGEL_LMS_TYPE_PLUGIN_FACTORY (rygel_lms_plugin_factory_get_type ())
#define RYGEL_LMS_PLUGIN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_LMS_TYPE_PLUGIN_FACTORY, RygelLMSPluginFactory))
#define RYGEL_LMS_PLUGIN_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_LMS_TYPE_PLUGIN_FACTORY, RygelLMSPluginFactoryClass))
#define RYGEL_LMS_IS_PLUGIN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_LMS_TYPE_PLUGIN_FACTORY))
#define RYGEL_LMS_IS_PLUGIN_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_LMS_TYPE_PLUGIN_FACTORY))
#define RYGEL_LMS_PLUGIN_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_LMS_TYPE_PLUGIN_FACTORY, RygelLMSPluginFactoryClass))

typedef struct _RygelLMSPluginFactory RygelLMSPluginFactory;
typedef struct _RygelLMSPluginFactoryClass RygelLMSPluginFactoryClass;
#define _rygel_lms_plugin_factory_unref0(var) ((var == NULL) ? NULL : (var = (rygel_lms_plugin_factory_unref (var), NULL)))
typedef struct _RygelLMSPluginFactoryPrivate RygelLMSPluginFactoryPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define RYGEL_LMS_TYPE_PLUGIN (rygel_lms_plugin_get_type ())
#define RYGEL_LMS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_LMS_TYPE_PLUGIN, RygelLMSPlugin))
#define RYGEL_LMS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_LMS_TYPE_PLUGIN, RygelLMSPluginClass))
#define RYGEL_LMS_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_LMS_TYPE_PLUGIN))
#define RYGEL_LMS_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_LMS_TYPE_PLUGIN))
#define RYGEL_LMS_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_LMS_TYPE_PLUGIN, RygelLMSPluginClass))

typedef struct _RygelLMSPlugin RygelLMSPlugin;
typedef struct _RygelLMSPluginClass RygelLMSPluginClass;
typedef struct _RygelLMSParamSpecPluginFactory RygelLMSParamSpecPluginFactory;

struct _RygelLMSPluginFactory {
	GTypeInstance parent_instance;
	volatile int ref_count;
	RygelLMSPluginFactoryPrivate * priv;
};

struct _RygelLMSPluginFactoryClass {
	GTypeClass parent_class;
	void (*finalize) (RygelLMSPluginFactory *self);
};

struct _RygelLMSPluginFactoryPrivate {
	RygelPluginLoader* loader;
};

struct _RygelLMSParamSpecPluginFactory {
	GParamSpec parent_instance;
};


extern RygelLMSPluginFactory* plugin_factory;
RygelLMSPluginFactory* plugin_factory = NULL;
static gpointer rygel_lms_plugin_factory_parent_class = NULL;

gpointer rygel_lms_plugin_factory_ref (gpointer instance);
void rygel_lms_plugin_factory_unref (gpointer instance);
GParamSpec* rygel_lms_param_spec_plugin_factory (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_lms_value_set_plugin_factory (GValue* value, gpointer v_object);
void rygel_lms_value_take_plugin_factory (GValue* value, gpointer v_object);
gpointer rygel_lms_value_get_plugin_factory (const GValue* value);
GType rygel_lms_plugin_factory_get_type (void) G_GNUC_CONST;
void module_init (RygelPluginLoader* loader);
RygelLMSPluginFactory* rygel_lms_plugin_factory_new (RygelPluginLoader* loader);
RygelLMSPluginFactory* rygel_lms_plugin_factory_construct (GType object_type, RygelPluginLoader* loader);
#define RYGEL_LMS_PLUGIN_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_LMS_TYPE_PLUGIN_FACTORY, RygelLMSPluginFactoryPrivate))
enum  {
	RYGEL_LMS_PLUGIN_FACTORY_DUMMY_PROPERTY
};
RygelLMSPlugin* rygel_lms_plugin_new (void);
RygelLMSPlugin* rygel_lms_plugin_construct (GType object_type);
GType rygel_lms_plugin_get_type (void) G_GNUC_CONST;
static void rygel_lms_plugin_factory_finalize (RygelLMSPluginFactory* obj);


void module_init (RygelPluginLoader* loader) {
	RygelPluginLoader* _tmp0_ = NULL;
	RygelLMSPluginFactory* _tmp1_ = NULL;
	g_return_if_fail (loader != NULL);
	_tmp0_ = loader;
	_tmp1_ = rygel_lms_plugin_factory_new (_tmp0_);
	_rygel_lms_plugin_factory_unref0 (plugin_factory);
	plugin_factory = _tmp1_;
}


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


RygelLMSPluginFactory* rygel_lms_plugin_factory_construct (GType object_type, RygelPluginLoader* loader) {
	RygelLMSPluginFactory* self = NULL;
	RygelPluginLoader* _tmp0_ = NULL;
	RygelPluginLoader* _tmp1_ = NULL;
	RygelPluginLoader* _tmp2_ = NULL;
	RygelLMSPlugin* _tmp3_ = NULL;
	RygelLMSPlugin* _tmp4_ = NULL;
	g_return_val_if_fail (loader != NULL, NULL);
	self = (RygelLMSPluginFactory*) g_type_create_instance (object_type);
	_tmp0_ = loader;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->loader);
	self->priv->loader = _tmp1_;
	_tmp2_ = self->priv->loader;
	_tmp3_ = rygel_lms_plugin_new ();
	_tmp4_ = _tmp3_;
	rygel_plugin_loader_add_plugin (_tmp2_, (RygelPlugin*) _tmp4_);
	_g_object_unref0 (_tmp4_);
	return self;
}


RygelLMSPluginFactory* rygel_lms_plugin_factory_new (RygelPluginLoader* loader) {
	return rygel_lms_plugin_factory_construct (RYGEL_LMS_TYPE_PLUGIN_FACTORY, loader);
}


static void rygel_lms_value_plugin_factory_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void rygel_lms_value_plugin_factory_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		rygel_lms_plugin_factory_unref (value->data[0].v_pointer);
	}
}


static void rygel_lms_value_plugin_factory_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = rygel_lms_plugin_factory_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer rygel_lms_value_plugin_factory_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* rygel_lms_value_plugin_factory_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		RygelLMSPluginFactory* object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = rygel_lms_plugin_factory_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* rygel_lms_value_plugin_factory_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	RygelLMSPluginFactory** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = rygel_lms_plugin_factory_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* rygel_lms_param_spec_plugin_factory (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	RygelLMSParamSpecPluginFactory* spec;
	g_return_val_if_fail (g_type_is_a (object_type, RYGEL_LMS_TYPE_PLUGIN_FACTORY), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer rygel_lms_value_get_plugin_factory (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_LMS_TYPE_PLUGIN_FACTORY), NULL);
	return value->data[0].v_pointer;
}


void rygel_lms_value_set_plugin_factory (GValue* value, gpointer v_object) {
	RygelLMSPluginFactory* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_LMS_TYPE_PLUGIN_FACTORY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_LMS_TYPE_PLUGIN_FACTORY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		rygel_lms_plugin_factory_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		rygel_lms_plugin_factory_unref (old);
	}
}


void rygel_lms_value_take_plugin_factory (GValue* value, gpointer v_object) {
	RygelLMSPluginFactory* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_LMS_TYPE_PLUGIN_FACTORY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_LMS_TYPE_PLUGIN_FACTORY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		rygel_lms_plugin_factory_unref (old);
	}
}


static void rygel_lms_plugin_factory_class_init (RygelLMSPluginFactoryClass * klass) {
	rygel_lms_plugin_factory_parent_class = g_type_class_peek_parent (klass);
	((RygelLMSPluginFactoryClass *) klass)->finalize = rygel_lms_plugin_factory_finalize;
	g_type_class_add_private (klass, sizeof (RygelLMSPluginFactoryPrivate));
}


static void rygel_lms_plugin_factory_instance_init (RygelLMSPluginFactory * self) {
	self->priv = RYGEL_LMS_PLUGIN_FACTORY_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void rygel_lms_plugin_factory_finalize (RygelLMSPluginFactory* obj) {
	RygelLMSPluginFactory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_LMS_TYPE_PLUGIN_FACTORY, RygelLMSPluginFactory);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->loader);
}


GType rygel_lms_plugin_factory_get_type (void) {
	static volatile gsize rygel_lms_plugin_factory_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_lms_plugin_factory_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { rygel_lms_value_plugin_factory_init, rygel_lms_value_plugin_factory_free_value, rygel_lms_value_plugin_factory_copy_value, rygel_lms_value_plugin_factory_peek_pointer, "p", rygel_lms_value_plugin_factory_collect_value, "p", rygel_lms_value_plugin_factory_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (RygelLMSPluginFactoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_lms_plugin_factory_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelLMSPluginFactory), 0, (GInstanceInitFunc) rygel_lms_plugin_factory_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType rygel_lms_plugin_factory_type_id;
		rygel_lms_plugin_factory_type_id = g_type_register_fundamental (g_type_fundamental_next (), "RygelLMSPluginFactory", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&rygel_lms_plugin_factory_type_id__volatile, rygel_lms_plugin_factory_type_id);
	}
	return rygel_lms_plugin_factory_type_id__volatile;
}


gpointer rygel_lms_plugin_factory_ref (gpointer instance) {
	RygelLMSPluginFactory* self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void rygel_lms_plugin_factory_unref (gpointer instance) {
	RygelLMSPluginFactory* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		RYGEL_LMS_PLUGIN_FACTORY_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



