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

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gee.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_DATA_OBJECT (data_object_get_type ())
#define DATA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATA_OBJECT, DataObject))
#define DATA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATA_OBJECT, DataObjectClass))
#define IS_DATA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATA_OBJECT))
#define IS_DATA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATA_OBJECT))
#define DATA_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATA_OBJECT, DataObjectClass))

typedef struct _DataObject DataObject;
typedef struct _DataObjectClass DataObjectClass;

#define TYPE_DATA_SOURCE (data_source_get_type ())
#define DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATA_SOURCE, DataSource))
#define DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATA_SOURCE, DataSourceClass))
#define IS_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATA_SOURCE))
#define IS_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATA_SOURCE))
#define DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATA_SOURCE, DataSourceClass))

typedef struct _DataSource DataSource;
typedef struct _DataSourceClass DataSourceClass;
typedef gint64 (*GetSourceDatabaseKey) (DataSource* source, gpointer user_data);

#define TYPE_DATA_COLLECTION (data_collection_get_type ())
#define DATA_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATA_COLLECTION, DataCollection))
#define DATA_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATA_COLLECTION, DataCollectionClass))
#define IS_DATA_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATA_COLLECTION))
#define IS_DATA_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATA_COLLECTION))
#define DATA_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATA_COLLECTION, DataCollectionClass))

typedef struct _DataCollection DataCollection;
typedef struct _DataCollectionClass DataCollectionClass;
typedef struct _DataCollectionPrivate DataCollectionPrivate;

#define TYPE_ALTERATION (alteration_get_type ())
#define ALTERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ALTERATION, Alteration))
#define ALTERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ALTERATION, AlterationClass))
#define IS_ALTERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ALTERATION))
#define IS_ALTERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ALTERATION))
#define ALTERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ALTERATION, AlterationClass))

typedef struct _Alteration Alteration;
typedef struct _AlterationClass AlterationClass;
typedef gint64 (*Comparator) (void* a, void* b, gpointer user_data);
typedef gboolean (*ComparatorPredicate) (DataObject* object, Alteration* alteration, gpointer user_data);
typedef gboolean (*ProgressMonitor) (guint64 current, guint64 total, gboolean do_event_loop, gpointer user_data);

#define TYPE_MARKER (marker_get_type ())
#define MARKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MARKER, Marker))
#define IS_MARKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MARKER))
#define MARKER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_MARKER, MarkerIface))

typedef struct _Marker Marker;
typedef struct _MarkerIface MarkerIface;

#define TYPE_SOURCE_COLLECTION (source_collection_get_type ())
#define SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SOURCE_COLLECTION, SourceCollection))
#define SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SOURCE_COLLECTION, SourceCollectionClass))
#define IS_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SOURCE_COLLECTION))
#define IS_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SOURCE_COLLECTION))
#define SOURCE_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SOURCE_COLLECTION, SourceCollectionClass))

typedef struct _SourceCollection SourceCollection;
typedef struct _SourceCollectionClass SourceCollectionClass;
typedef struct _SourceCollectionPrivate SourceCollectionPrivate;

#define TYPE_SOURCE_BACKLINK (source_backlink_get_type ())
#define SOURCE_BACKLINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SOURCE_BACKLINK, SourceBacklink))
#define SOURCE_BACKLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SOURCE_BACKLINK, SourceBacklinkClass))
#define IS_SOURCE_BACKLINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SOURCE_BACKLINK))
#define IS_SOURCE_BACKLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SOURCE_BACKLINK))
#define SOURCE_BACKLINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SOURCE_BACKLINK, SourceBacklinkClass))

typedef struct _SourceBacklink SourceBacklink;
typedef struct _SourceBacklinkClass SourceBacklinkClass;

#define TYPE_DATABASE_SOURCE_COLLECTION (database_source_collection_get_type ())
#define DATABASE_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollection))
#define DATABASE_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollectionClass))
#define IS_DATABASE_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATABASE_SOURCE_COLLECTION))
#define IS_DATABASE_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATABASE_SOURCE_COLLECTION))
#define DATABASE_SOURCE_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollectionClass))

typedef struct _DatabaseSourceCollection DatabaseSourceCollection;
typedef struct _DatabaseSourceCollectionClass DatabaseSourceCollectionClass;
typedef struct _DatabaseSourceCollectionPrivate DatabaseSourceCollectionPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_SOURCE_HOLDING_TANK (source_holding_tank_get_type ())
#define SOURCE_HOLDING_TANK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SOURCE_HOLDING_TANK, SourceHoldingTank))
#define SOURCE_HOLDING_TANK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SOURCE_HOLDING_TANK, SourceHoldingTankClass))
#define IS_SOURCE_HOLDING_TANK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SOURCE_HOLDING_TANK))
#define IS_SOURCE_HOLDING_TANK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SOURCE_HOLDING_TANK))
#define SOURCE_HOLDING_TANK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SOURCE_HOLDING_TANK, SourceHoldingTankClass))

typedef struct _SourceHoldingTank SourceHoldingTank;
typedef struct _SourceHoldingTankClass SourceHoldingTankClass;
typedef struct _SourceHoldingTankPrivate SourceHoldingTankPrivate;

#define TYPE_DATABASE_SOURCE_HOLDING_TANK (database_source_holding_tank_get_type ())
#define DATABASE_SOURCE_HOLDING_TANK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATABASE_SOURCE_HOLDING_TANK, DatabaseSourceHoldingTank))
#define DATABASE_SOURCE_HOLDING_TANK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATABASE_SOURCE_HOLDING_TANK, DatabaseSourceHoldingTankClass))
#define IS_DATABASE_SOURCE_HOLDING_TANK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATABASE_SOURCE_HOLDING_TANK))
#define IS_DATABASE_SOURCE_HOLDING_TANK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATABASE_SOURCE_HOLDING_TANK))
#define DATABASE_SOURCE_HOLDING_TANK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATABASE_SOURCE_HOLDING_TANK, DatabaseSourceHoldingTankClass))

typedef struct _DatabaseSourceHoldingTank DatabaseSourceHoldingTank;
typedef struct _DatabaseSourceHoldingTankClass DatabaseSourceHoldingTankClass;
typedef struct _DatabaseSourceHoldingTankPrivate DatabaseSourceHoldingTankPrivate;
typedef gboolean (*SourceHoldingTankCheckToKeep) (DataSource* source, Alteration* alteration, gpointer user_data);
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _MarkerIface {
	GTypeInterface parent_iface;
	void (*mark) (Marker* self, DataObject* object);
	void (*unmark) (Marker* self, DataObject* object);
	gboolean (*toggle) (Marker* self, DataObject* object);
	void (*mark_many) (Marker* self, GeeCollection* list);
	void (*unmark_many) (Marker* self, GeeCollection* list);
	void (*mark_all) (Marker* self);
	gint (*get_count) (Marker* self);
	GeeCollection* (*get_all) (Marker* self);
};

struct _DataCollection {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DataCollectionPrivate * priv;
};

struct _DataCollectionClass {
	GTypeClass parent_class;
	void (*finalize) (DataCollection *self);
	gchar* (*to_string) (DataCollection* self);
	void (*notify_items_added) (DataCollection* self, GeeIterable* added);
	void (*notify_items_removed) (DataCollection* self, GeeIterable* removed);
	void (*notify_contents_altered) (DataCollection* self, GeeIterable* added, GeeIterable* removed);
	void (*notify_items_altered) (DataCollection* self, GeeMap* items);
	void (*notify_ordering_changed) (DataCollection* self);
	void (*notify_property_set) (DataCollection* self, const gchar* name, GValue* old, GValue* val);
	void (*notify_property_cleared) (DataCollection* self, const gchar* name);
	gboolean (*valid_type) (DataCollection* self, DataObject* object);
	void (*set_comparator) (DataCollection* self, Comparator comparator, gpointer comparator_target, ComparatorPredicate predicate, gpointer predicate_target);
	void (*reset_comparator) (DataCollection* self);
	GeeCollection* (*get_all) (DataCollection* self);
	gint (*get_count) (DataCollection* self);
	DataObject* (*get_at) (DataCollection* self, gint index);
	gint (*index_of) (DataCollection* self, DataObject* object);
	gboolean (*contains) (DataCollection* self, DataObject* object);
	gboolean (*add) (DataCollection* self, DataObject* object);
	GeeCollection* (*add_many) (DataCollection* self, GeeCollection* objects, ProgressMonitor monitor, gpointer monitor_target);
	void (*remove_marked) (DataCollection* self, Marker* m);
	void (*clear) (DataCollection* self);
	void (*close) (DataCollection* self);
	void (*notify_frozen) (DataCollection* self);
	void (*notify_thawed) (DataCollection* self);
	void (*items_added) (DataCollection* self, GeeIterable* added);
	void (*items_removed) (DataCollection* self, GeeIterable* removed);
	void (*contents_altered) (DataCollection* self, GeeIterable* added, GeeIterable* removed);
	void (*items_altered) (DataCollection* self, GeeMap* items);
	void (*ordering_changed) (DataCollection* self);
	void (*property_set) (DataCollection* self, const gchar* name, GValue* old, GValue* val);
	void (*property_cleared) (DataCollection* self, const gchar* name);
	void (*frozen) (DataCollection* self);
	void (*thawed) (DataCollection* self);
};

struct _SourceCollection {
	DataCollection parent_instance;
	SourceCollectionPrivate * priv;
};

struct _SourceCollectionClass {
	DataCollectionClass parent_class;
	gboolean (*holds_type_of_source) (SourceCollection* self, DataSource* source);
	void (*notify_items_unlinking) (SourceCollection* self, GeeCollection* unlinking);
	void (*notify_items_relinked) (SourceCollection* self, GeeCollection* relinked);
	void (*notify_item_destroyed) (SourceCollection* self, DataSource* source);
	void (*notify_items_destroyed) (SourceCollection* self, GeeCollection* destroyed);
	void (*notify_unlinked_destroyed) (SourceCollection* self, DataSource* unlinked);
	void (*notify_backlink_removed) (SourceCollection* self, SourceBacklink* backlink, GeeCollection* sources);
	gboolean (*has_backlink) (SourceCollection* self, SourceBacklink* backlink);
	void (*remove_backlink) (SourceCollection* self, SourceBacklink* backlink);
	void (*items_unlinking) (SourceCollection* self, GeeCollection* unlinking);
	void (*items_relinked) (SourceCollection* self, GeeCollection* relinked);
	void (*item_destroyed) (SourceCollection* self, DataSource* source);
	void (*items_destroyed) (SourceCollection* self, GeeCollection* destroyed);
	void (*unlinked_destroyed) (SourceCollection* self, DataSource* source);
	void (*backlink_removed) (SourceCollection* self, SourceBacklink* backlink, GeeCollection* sources);
};

struct _DatabaseSourceCollection {
	SourceCollection parent_instance;
	DatabaseSourceCollectionPrivate * priv;
};

struct _DatabaseSourceCollectionClass {
	SourceCollectionClass parent_class;
};

struct _DatabaseSourceCollectionPrivate {
	GetSourceDatabaseKey source_key_func;
	gpointer source_key_func_target;
	GeeHashMap* map;
};

struct _SourceHoldingTank {
	GTypeInstance parent_instance;
	volatile int ref_count;
	SourceHoldingTankPrivate * priv;
};

struct _SourceHoldingTankClass {
	GTypeClass parent_class;
	void (*finalize) (SourceHoldingTank *self);
	void (*notify_contents_altered) (SourceHoldingTank* self, GeeCollection* added, GeeCollection* removed);
	void (*contents_altered) (SourceHoldingTank* self, GeeCollection* added, GeeCollection* removed);
};

struct _DatabaseSourceHoldingTank {
	SourceHoldingTank parent_instance;
	DatabaseSourceHoldingTankPrivate * priv;
};

struct _DatabaseSourceHoldingTankClass {
	SourceHoldingTankClass parent_class;
};

struct _DatabaseSourceHoldingTankPrivate {
	GetSourceDatabaseKey get_key;
	gpointer get_key_target;
	GeeHashMap* map;
};

static gint DatabaseSourceCollection_private_offset;
static gpointer database_source_collection_parent_class = NULL;
static gint DatabaseSourceHoldingTank_private_offset;
static gpointer database_source_holding_tank_parent_class = NULL;

VALA_EXTERN GType data_object_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DataObject, g_object_unref)
VALA_EXTERN GType data_source_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DataSource, g_object_unref)
VALA_EXTERN gpointer data_collection_ref (gpointer instance);
VALA_EXTERN void data_collection_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_data_collection (const gchar* name,
                                        const gchar* nick,
                                        const gchar* blurb,
                                        GType object_type,
                                        GParamFlags flags);
VALA_EXTERN void value_set_data_collection (GValue* value,
                                gpointer v_object);
VALA_EXTERN void value_take_data_collection (GValue* value,
                                 gpointer v_object);
VALA_EXTERN gpointer value_get_data_collection (const GValue* value);
VALA_EXTERN GType data_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DataCollection, data_collection_unref)
VALA_EXTERN gpointer alteration_ref (gpointer instance);
VALA_EXTERN void alteration_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_alteration (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags);
VALA_EXTERN void value_set_alteration (GValue* value,
                           gpointer v_object);
VALA_EXTERN void value_take_alteration (GValue* value,
                            gpointer v_object);
VALA_EXTERN gpointer value_get_alteration (const GValue* value);
VALA_EXTERN GType alteration_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Alteration, alteration_unref)
VALA_EXTERN GType marker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Marker, g_object_unref)
VALA_EXTERN GType source_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SourceCollection, data_collection_unref)
VALA_EXTERN gpointer source_backlink_ref (gpointer instance);
VALA_EXTERN void source_backlink_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_source_backlink (const gchar* name,
                                        const gchar* nick,
                                        const gchar* blurb,
                                        GType object_type,
                                        GParamFlags flags);
VALA_EXTERN void value_set_source_backlink (GValue* value,
                                gpointer v_object);
VALA_EXTERN void value_take_source_backlink (GValue* value,
                                 gpointer v_object);
VALA_EXTERN gpointer value_get_source_backlink (const GValue* value);
VALA_EXTERN GType source_backlink_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SourceBacklink, source_backlink_unref)
VALA_EXTERN GType database_source_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DatabaseSourceCollection, data_collection_unref)
VALA_EXTERN void data_collection_notify_items_added (DataCollection* self,
                                         GeeIterable* added);
VALA_EXTERN void data_collection_notify_items_removed (DataCollection* self,
                                           GeeIterable* removed);
VALA_EXTERN guint int64_hash (gint64* n);
static guint _int64_hash_gee_hash_data_func (gconstpointer v,
                                      gpointer self);
VALA_EXTERN gboolean int64_equal (gint64* a,
                      gint64* b);
static gboolean _int64_equal_gee_equal_data_func (gconstpointer a,
                                           gconstpointer b,
                                           gpointer self);
static gint64* _int64_dup (gint64* self);
VALA_EXTERN DatabaseSourceCollection* database_source_collection_construct (GType object_type,
                                                                const gchar* name,
                                                                GetSourceDatabaseKey source_key_func,
                                                                gpointer source_key_func_target);
VALA_EXTERN SourceCollection* source_collection_construct (GType object_type,
                                               const gchar* name);
static void database_source_collection_real_notify_items_added (DataCollection* base,
                                                         GeeIterable* added);
static void database_source_collection_real_notify_items_removed (DataCollection* base,
                                                           GeeIterable* removed);
VALA_EXTERN DataSource* database_source_collection_fetch_by_key (DatabaseSourceCollection* self,
                                                     gint64 key);
static void database_source_collection_finalize (DataCollection * obj);
static GType database_source_collection_get_type_once (void);
VALA_EXTERN gpointer source_holding_tank_ref (gpointer instance);
VALA_EXTERN void source_holding_tank_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_source_holding_tank (const gchar* name,
                                            const gchar* nick,
                                            const gchar* blurb,
                                            GType object_type,
                                            GParamFlags flags);
VALA_EXTERN void value_set_source_holding_tank (GValue* value,
                                    gpointer v_object);
VALA_EXTERN void value_take_source_holding_tank (GValue* value,
                                     gpointer v_object);
VALA_EXTERN gpointer value_get_source_holding_tank (const GValue* value);
VALA_EXTERN GType source_holding_tank_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SourceHoldingTank, source_holding_tank_unref)
VALA_EXTERN GType database_source_holding_tank_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DatabaseSourceHoldingTank, source_holding_tank_unref)
VALA_EXTERN void source_holding_tank_notify_contents_altered (SourceHoldingTank* self,
                                                  GeeCollection* added,
                                                  GeeCollection* removed);
VALA_EXTERN DatabaseSourceHoldingTank* database_source_holding_tank_new (SourceCollection* sources,
                                                             SourceHoldingTankCheckToKeep check_to_keep,
                                                             gpointer check_to_keep_target,
                                                             GetSourceDatabaseKey get_key,
                                                             gpointer get_key_target);
VALA_EXTERN DatabaseSourceHoldingTank* database_source_holding_tank_construct (GType object_type,
                                                                   SourceCollection* sources,
                                                                   SourceHoldingTankCheckToKeep check_to_keep,
                                                                   gpointer check_to_keep_target,
                                                                   GetSourceDatabaseKey get_key,
                                                                   gpointer get_key_target);
VALA_EXTERN SourceHoldingTank* source_holding_tank_new (SourceCollection* sources,
                                            SourceHoldingTankCheckToKeep check_to_keep,
                                            gpointer check_to_keep_target);
VALA_EXTERN SourceHoldingTank* source_holding_tank_construct (GType object_type,
                                                  SourceCollection* sources,
                                                  SourceHoldingTankCheckToKeep check_to_keep,
                                                  gpointer check_to_keep_target);
VALA_EXTERN DataSource* database_source_holding_tank_get_by_id (DatabaseSourceHoldingTank* self,
                                                    gint64 id);
static void database_source_holding_tank_real_notify_contents_altered (SourceHoldingTank* base,
                                                                GeeCollection* added,
                                                                GeeCollection* removed);
static void database_source_holding_tank_finalize (SourceHoldingTank * obj);
static GType database_source_holding_tank_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
database_source_collection_get_instance_private (DatabaseSourceCollection* self)
{
	return G_STRUCT_MEMBER_P (self, DatabaseSourceCollection_private_offset);
}

static guint
_int64_hash_gee_hash_data_func (gconstpointer v,
                                gpointer self)
{
	guint result;
	result = int64_hash ((gint64*) v);
	return result;
}

static gboolean
_int64_equal_gee_equal_data_func (gconstpointer a,
                                  gconstpointer b,
                                  gpointer self)
{
	gboolean result;
	result = int64_equal ((gint64*) a, (gint64*) b);
	return result;
}

static gint64*
_int64_dup (gint64* self)
{
	gint64* dup;
	dup = g_new0 (gint64, 1);
	memcpy (dup, self, sizeof (gint64));
	return dup;
}

DatabaseSourceCollection*
database_source_collection_construct (GType object_type,
                                      const gchar* name,
                                      GetSourceDatabaseKey source_key_func,
                                      gpointer source_key_func_target)
{
	DatabaseSourceCollection* self = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	self = (DatabaseSourceCollection*) source_collection_construct (object_type, name);
	self->priv->source_key_func = source_key_func;
	self->priv->source_key_func_target = source_key_func_target;
	return self;
}

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

static void
database_source_collection_real_notify_items_added (DataCollection* base,
                                                    GeeIterable* added)
{
	DatabaseSourceCollection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollection);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (added, GEE_TYPE_ITERABLE));
	{
		GeeIterator* _object_it = NULL;
		GeeIterator* _tmp0_;
		_tmp0_ = gee_iterable_iterator (added);
		_object_it = _tmp0_;
		while (TRUE) {
			GeeIterator* _tmp1_;
			DataObject* object = NULL;
			GeeIterator* _tmp2_;
			gpointer _tmp3_;
			DataSource* source = NULL;
			DataObject* _tmp4_;
			DataSource* _tmp5_;
			gint64 key = 0LL;
			GetSourceDatabaseKey _tmp6_;
			gpointer _tmp6__target;
			DataSource* _tmp7_;
			GeeHashMap* _tmp8_;
			GeeHashMap* _tmp9_;
			DataSource* _tmp10_;
			_tmp1_ = _object_it;
			if (!gee_iterator_next (_tmp1_)) {
				break;
			}
			_tmp2_ = _object_it;
			_tmp3_ = gee_iterator_get (_tmp2_);
			object = (DataObject*) _tmp3_;
			_tmp4_ = object;
			_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TYPE_DATA_SOURCE, DataSource));
			source = _tmp5_;
			_tmp6_ = self->priv->source_key_func;
			_tmp6__target = self->priv->source_key_func_target;
			_tmp7_ = source;
			key = _tmp6_ (_tmp7_, _tmp6__target);
			_tmp8_ = self->priv->map;
			_vala_assert (!gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), &key), "!map.has_key(key)");
			_tmp9_ = self->priv->map;
			_tmp10_ = source;
			gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), &key, _tmp10_);
			_g_object_unref0 (source);
			_g_object_unref0 (object);
		}
		_g_object_unref0 (_object_it);
	}
	DATA_COLLECTION_CLASS (database_source_collection_parent_class)->notify_items_added (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SOURCE_COLLECTION, SourceCollection), TYPE_DATA_COLLECTION, DataCollection), added);
}

static void
database_source_collection_real_notify_items_removed (DataCollection* base,
                                                      GeeIterable* removed)
{
	DatabaseSourceCollection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollection);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_ITERABLE));
	{
		GeeIterator* _object_it = NULL;
		GeeIterator* _tmp0_;
		_tmp0_ = gee_iterable_iterator (removed);
		_object_it = _tmp0_;
		while (TRUE) {
			GeeIterator* _tmp1_;
			DataObject* object = NULL;
			GeeIterator* _tmp2_;
			gpointer _tmp3_;
			gint64 key = 0LL;
			GetSourceDatabaseKey _tmp4_;
			gpointer _tmp4__target;
			DataObject* _tmp5_;
			gboolean is_removed = FALSE;
			GeeHashMap* _tmp6_;
			_tmp1_ = _object_it;
			if (!gee_iterator_next (_tmp1_)) {
				break;
			}
			_tmp2_ = _object_it;
			_tmp3_ = gee_iterator_get (_tmp2_);
			object = (DataObject*) _tmp3_;
			_tmp4_ = self->priv->source_key_func;
			_tmp4__target = self->priv->source_key_func_target;
			_tmp5_ = object;
			key = _tmp4_ (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, TYPE_DATA_SOURCE, DataSource), _tmp4__target);
			_tmp6_ = self->priv->map;
			is_removed = gee_abstract_map_unset (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), &key, NULL);
			_vala_assert (is_removed, "is_removed");
			_g_object_unref0 (object);
		}
		_g_object_unref0 (_object_it);
	}
	DATA_COLLECTION_CLASS (database_source_collection_parent_class)->notify_items_removed (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SOURCE_COLLECTION, SourceCollection), TYPE_DATA_COLLECTION, DataCollection), removed);
}

DataSource*
database_source_collection_fetch_by_key (DatabaseSourceCollection* self,
                                         gint64 key)
{
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	DataSource* result;
	g_return_val_if_fail (IS_DATABASE_SOURCE_COLLECTION (self), NULL);
	_tmp0_ = self->priv->map;
	_tmp1_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), &key);
	result = (DataSource*) _tmp1_;
	return result;
}

static void
database_source_collection_class_init (DatabaseSourceCollectionClass * klass,
                                       gpointer klass_data)
{
	database_source_collection_parent_class = g_type_class_peek_parent (klass);
	((DataCollectionClass *) klass)->finalize = database_source_collection_finalize;
	g_type_class_adjust_private_offset (klass, &DatabaseSourceCollection_private_offset);
	((DataCollectionClass *) klass)->notify_items_added = (void (*) (DataCollection*, GeeIterable*)) database_source_collection_real_notify_items_added;
	((DataCollectionClass *) klass)->notify_items_removed = (void (*) (DataCollection*, GeeIterable*)) database_source_collection_real_notify_items_removed;
}

static void
database_source_collection_instance_init (DatabaseSourceCollection * self,
                                          gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = database_source_collection_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_INT64, (GBoxedCopyFunc) _int64_dup, (GDestroyNotify) g_free, TYPE_DATA_SOURCE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _int64_hash_gee_hash_data_func, NULL, NULL, _int64_equal_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->map = _tmp0_;
}

static void
database_source_collection_finalize (DataCollection * obj)
{
	DatabaseSourceCollection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollection);
	_g_object_unref0 (self->priv->map);
	DATA_COLLECTION_CLASS (database_source_collection_parent_class)->finalize (obj);
}

static GType
database_source_collection_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DatabaseSourceCollectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) database_source_collection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DatabaseSourceCollection), 0, (GInstanceInitFunc) database_source_collection_instance_init, NULL };
	GType database_source_collection_type_id;
	database_source_collection_type_id = g_type_register_static (TYPE_SOURCE_COLLECTION, "DatabaseSourceCollection", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	DatabaseSourceCollection_private_offset = g_type_add_instance_private (database_source_collection_type_id, sizeof (DatabaseSourceCollectionPrivate));
	return database_source_collection_type_id;
}

GType
database_source_collection_get_type (void)
{
	static volatile gsize database_source_collection_type_id__once = 0;
	if (g_once_init_enter (&database_source_collection_type_id__once)) {
		GType database_source_collection_type_id;
		database_source_collection_type_id = database_source_collection_get_type_once ();
		g_once_init_leave (&database_source_collection_type_id__once, database_source_collection_type_id);
	}
	return database_source_collection_type_id__once;
}

static inline gpointer
database_source_holding_tank_get_instance_private (DatabaseSourceHoldingTank* self)
{
	return G_STRUCT_MEMBER_P (self, DatabaseSourceHoldingTank_private_offset);
}

DatabaseSourceHoldingTank*
database_source_holding_tank_construct (GType object_type,
                                        SourceCollection* sources,
                                        SourceHoldingTankCheckToKeep check_to_keep,
                                        gpointer check_to_keep_target,
                                        GetSourceDatabaseKey get_key,
                                        gpointer get_key_target)
{
	DatabaseSourceHoldingTank* self = NULL;
	g_return_val_if_fail (IS_SOURCE_COLLECTION (sources), NULL);
	self = (DatabaseSourceHoldingTank*) source_holding_tank_construct (object_type, sources, check_to_keep, check_to_keep_target);
	self->priv->get_key = get_key;
	self->priv->get_key_target = get_key_target;
	return self;
}

DatabaseSourceHoldingTank*
database_source_holding_tank_new (SourceCollection* sources,
                                  SourceHoldingTankCheckToKeep check_to_keep,
                                  gpointer check_to_keep_target,
                                  GetSourceDatabaseKey get_key,
                                  gpointer get_key_target)
{
	return database_source_holding_tank_construct (TYPE_DATABASE_SOURCE_HOLDING_TANK, sources, check_to_keep, check_to_keep_target, get_key, get_key_target);
}

DataSource*
database_source_holding_tank_get_by_id (DatabaseSourceHoldingTank* self,
                                        gint64 id)
{
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	DataSource* result;
	g_return_val_if_fail (IS_DATABASE_SOURCE_HOLDING_TANK (self), NULL);
	_tmp0_ = self->priv->map;
	_tmp1_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), &id);
	result = (DataSource*) _tmp1_;
	return result;
}

static void
database_source_holding_tank_real_notify_contents_altered (SourceHoldingTank* base,
                                                           GeeCollection* added,
                                                           GeeCollection* removed)
{
	DatabaseSourceHoldingTank * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DATABASE_SOURCE_HOLDING_TANK, DatabaseSourceHoldingTank);
	g_return_if_fail ((added == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (added, GEE_TYPE_COLLECTION));
	g_return_if_fail ((removed == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION));
	if (added != NULL) {
		{
			GeeIterator* _source_it = NULL;
			GeeIterator* _tmp0_;
			_tmp0_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (added, GEE_TYPE_ITERABLE, GeeIterable));
			_source_it = _tmp0_;
			while (TRUE) {
				GeeIterator* _tmp1_;
				DataSource* source = NULL;
				GeeIterator* _tmp2_;
				gpointer _tmp3_;
				GeeHashMap* _tmp4_;
				GetSourceDatabaseKey _tmp5_;
				gpointer _tmp5__target;
				DataSource* _tmp6_;
				gint64 _tmp7_;
				DataSource* _tmp8_;
				_tmp1_ = _source_it;
				if (!gee_iterator_next (_tmp1_)) {
					break;
				}
				_tmp2_ = _source_it;
				_tmp3_ = gee_iterator_get (_tmp2_);
				source = (DataSource*) _tmp3_;
				_tmp4_ = self->priv->map;
				_tmp5_ = self->priv->get_key;
				_tmp5__target = self->priv->get_key_target;
				_tmp6_ = source;
				_tmp7_ = _tmp5_ (_tmp6_, _tmp5__target);
				_tmp8_ = source;
				gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), &_tmp7_, _tmp8_);
				_g_object_unref0 (source);
			}
			_g_object_unref0 (_source_it);
		}
	}
	if (removed != NULL) {
		{
			GeeIterator* _source_it = NULL;
			GeeIterator* _tmp9_;
			_tmp9_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (removed, GEE_TYPE_ITERABLE, GeeIterable));
			_source_it = _tmp9_;
			while (TRUE) {
				GeeIterator* _tmp10_;
				DataSource* source = NULL;
				GeeIterator* _tmp11_;
				gpointer _tmp12_;
				GeeHashMap* _tmp13_;
				GetSourceDatabaseKey _tmp14_;
				gpointer _tmp14__target;
				DataSource* _tmp15_;
				gint64 _tmp16_;
				_tmp10_ = _source_it;
				if (!gee_iterator_next (_tmp10_)) {
					break;
				}
				_tmp11_ = _source_it;
				_tmp12_ = gee_iterator_get (_tmp11_);
				source = (DataSource*) _tmp12_;
				_tmp13_ = self->priv->map;
				_tmp14_ = self->priv->get_key;
				_tmp14__target = self->priv->get_key_target;
				_tmp15_ = source;
				_tmp16_ = _tmp14_ (_tmp15_, _tmp14__target);
				gee_abstract_map_unset (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), &_tmp16_, NULL);
				_g_object_unref0 (source);
			}
			_g_object_unref0 (_source_it);
		}
	}
	SOURCE_HOLDING_TANK_CLASS (database_source_holding_tank_parent_class)->notify_contents_altered (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SOURCE_HOLDING_TANK, SourceHoldingTank), added, removed);
}

static void
database_source_holding_tank_class_init (DatabaseSourceHoldingTankClass * klass,
                                         gpointer klass_data)
{
	database_source_holding_tank_parent_class = g_type_class_peek_parent (klass);
	((SourceHoldingTankClass *) klass)->finalize = database_source_holding_tank_finalize;
	g_type_class_adjust_private_offset (klass, &DatabaseSourceHoldingTank_private_offset);
	((SourceHoldingTankClass *) klass)->notify_contents_altered = (void (*) (SourceHoldingTank*, GeeCollection*, GeeCollection*)) database_source_holding_tank_real_notify_contents_altered;
}

static void
database_source_holding_tank_instance_init (DatabaseSourceHoldingTank * self,
                                            gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = database_source_holding_tank_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_INT64, (GBoxedCopyFunc) _int64_dup, (GDestroyNotify) g_free, TYPE_DATA_SOURCE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _int64_hash_gee_hash_data_func, NULL, NULL, _int64_equal_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->map = _tmp0_;
}

static void
database_source_holding_tank_finalize (SourceHoldingTank * obj)
{
	DatabaseSourceHoldingTank * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DATABASE_SOURCE_HOLDING_TANK, DatabaseSourceHoldingTank);
	_g_object_unref0 (self->priv->map);
	SOURCE_HOLDING_TANK_CLASS (database_source_holding_tank_parent_class)->finalize (obj);
}

static GType
database_source_holding_tank_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DatabaseSourceHoldingTankClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) database_source_holding_tank_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DatabaseSourceHoldingTank), 0, (GInstanceInitFunc) database_source_holding_tank_instance_init, NULL };
	GType database_source_holding_tank_type_id;
	database_source_holding_tank_type_id = g_type_register_static (TYPE_SOURCE_HOLDING_TANK, "DatabaseSourceHoldingTank", &g_define_type_info, 0);
	DatabaseSourceHoldingTank_private_offset = g_type_add_instance_private (database_source_holding_tank_type_id, sizeof (DatabaseSourceHoldingTankPrivate));
	return database_source_holding_tank_type_id;
}

GType
database_source_holding_tank_get_type (void)
{
	static volatile gsize database_source_holding_tank_type_id__once = 0;
	if (g_once_init_enter (&database_source_holding_tank_type_id__once)) {
		GType database_source_holding_tank_type_id;
		database_source_holding_tank_type_id = database_source_holding_tank_get_type_once ();
		g_once_init_leave (&database_source_holding_tank_type_id__once, database_source_holding_tank_type_id);
	}
	return database_source_holding_tank_type_id__once;
}

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

