/* Chrysalide - Outil d'analyse de fichiers binaires * content.c - lecture de données binaires quelconques * * Copyright (C) 2016 Cyrille Bagard * * This file is part of Chrysalide. * * Chrysalide 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. * * Chrysalide 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 Foobar. If not, see . */ #include "instance.h" #include #include "instance-int.h" /* Procède à l'initialisation de l'interface de partage. */ static void g_shared_instance_default_init(GSharedInstanceInterface *); /* Détermine le type d'une interface pour le partage d'instance. */ G_DEFINE_INTERFACE(GSharedInstance, g_shared_instance, G_TYPE_OBJECT) /****************************************************************************** * * * Paramètres : iface = interface GTK à initialiser. * * * * Description : Procède à l'initialisation de l'interface de partage. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_shared_instance_default_init(GSharedInstanceInterface *iface) { } /****************************************************************************** * * * Paramètres : instance = objet partagé à initialiser. * * info = information à utiliser pour la mise en place. * * * * Description : Initialise un nouvel objet partagé avec des informations. * * * * Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ bool g_shared_instance_init(GSharedInstance *instance, const void *info) { bool result; /* Bilan à retourner */ GSharedInstanceIface *iface; /* Interface utilisée */ iface = G_SHARED_INSTANCE_GET_IFACE(instance); result = iface->init(instance, info); return result; } /****************************************************************************** * * * Paramètres : instance = objet partagé à consulter. * * * * Description : Fournit la valeur du compteur de partage. * * * * Retour : Nombre de partages courant. * * * * Remarques : - * * * ******************************************************************************/ unsigned int g_shared_instance_get_references(const GSharedInstance *instance) { GSharedInstanceIface *iface; /* Interface utilisée */ iface = G_SHARED_INSTANCE_GET_IFACE(instance); return iface->get_ref(instance); } /****************************************************************************** * * * Paramètres : instance = objet partagé à modifier. * * * * Description : Incrémente le compteur de partage. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ void g_shared_instance_inc_references(GSharedInstance *instance) { GSharedInstanceIface *iface; /* Interface utilisée */ iface = G_SHARED_INSTANCE_GET_IFACE(instance); iface->inc_ref(instance); } /****************************************************************************** * * * Paramètres : instance = objet partagé à modifier. * * * * Description : Décrémente le compteur de partage. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ void g_shared_instance_dec_references(GSharedInstance *instance) { GSharedInstanceIface *iface; /* Interface utilisée */ iface = G_SHARED_INSTANCE_GET_IFACE(instance); iface->dec_ref(instance); } /****************************************************************************** * * * Paramètres : instance = objet partagé à consulter. * * info = compilation de d'information à analyser. * * * * Description : Indique l'objet partagé correspond à une description donnée. * * * * Retour : true si les détails centraux sont partagés, false sinon. * * * * Remarques : - * * * ******************************************************************************/ gboolean g_shared_instance_compare_info(const GSharedInstance *instance, const void *info) { bool result; /* Bilan à retourner */ GSharedInstanceIface *iface; /* Interface utilisée */ iface = G_SHARED_INSTANCE_GET_IFACE(instance); result = iface->cmp_info(instance, info); return result; } /****************************************************************************** * * * Paramètres : a = première instance d'objet partagé à comparer. * * b = second instance d'objet partagé à comparer. * * * * Description : Détermine si deux instances partagées sont identiques. * * * * Retour : TRUE si les deux éléments partagés sont identiques, ou FALSE.* * * * Remarques : - * * * ******************************************************************************/ gboolean g_shared_instance_is_equal(const GSharedInstance *a, const GSharedInstance *b) { gboolean result; /* Bilan à retourner */ GSharedInstanceIface *iface; /* Interface utilisée */ assert(G_OBJECT_TYPE(a) == G_OBJECT_TYPE(b)); iface = G_SHARED_INSTANCE_GET_IFACE(a); result = iface->is_equal(a, b); return result; }