2 * reactos Cache Manager (Cc*) PrivateBcb Map type structure of libcaptive
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "privatebcbmap.h" /* self */
23 #include "privatebcb.h"
24 #include "privatebcb-priv.h"
25 #include "sharedcachemap-priv.h"
26 #include <glib-object.h>
29 struct _CaptivePrivateBcbMapObject {
30 CaptivePrivateBcbObject parent_instance;
32 struct _CaptivePrivateBcbMapObjectClass {
33 CaptivePrivateBcbObjectClass parent_class;
37 static gpointer captive_private_bcb_map_object_parent_class=NULL;
40 static void captive_private_bcb_map_object_finalize(CaptivePrivateBcbMapObject *captive_private_bcb_map_object)
42 CaptivePrivateBcbObject *captive_private_bcb_object;
43 CaptiveSharedCacheMapObject *captive_shared_cache_map_object;
45 g_return_if_fail(captive_private_bcb_map_object!=NULL);
47 captive_private_bcb_object=CAPTIVE_PRIVATE_BCB_OBJECT(captive_private_bcb_map_object);
49 if ((captive_shared_cache_map_object=captive_private_bcb_object->SharedCacheMap)) {
50 g_assert(captive_shared_cache_map_object->map==captive_private_bcb_map_object);
51 captive_shared_cache_map_object->map=NULL;
52 g_object_unref(captive_shared_cache_map_object); /* 'map' disconnected. */
55 G_OBJECT_CLASS(captive_private_bcb_map_object_parent_class)->finalize((GObject *)captive_private_bcb_map_object);
59 static void captive_private_bcb_map_object_class_init(CaptivePrivateBcbMapObjectClass *class)
61 GObjectClass *gobject_class=G_OBJECT_CLASS(class);
63 captive_private_bcb_map_object_parent_class=g_type_class_ref(g_type_parent(G_TYPE_FROM_CLASS(class)));
64 gobject_class->finalize=(void (*)(GObject *object))captive_private_bcb_map_object_finalize;
68 static void captive_private_bcb_map_object_init(CaptivePrivateBcbMapObject *captive_private_bcb_map_object)
73 GType captive_private_bcb_map_object_get_type(void)
75 static GType captive_private_bcb_map_object_type=0;
77 if (!captive_private_bcb_map_object_type) {
78 static const GTypeInfo captive_private_bcb_map_object_info={
79 sizeof(CaptivePrivateBcbMapObjectClass),
81 NULL, /* base_finalize */
82 (GClassInitFunc)captive_private_bcb_map_object_class_init,
83 NULL, /* class_finalize */
84 NULL, /* class_data */
85 sizeof(CaptivePrivateBcbMapObject),
87 (GInstanceInitFunc)captive_private_bcb_map_object_init,
90 captive_private_bcb_map_object_type=g_type_register_static(CAPTIVE_PRIVATE_BCB_TYPE_OBJECT,
91 "CaptivePrivateBcbMapObject",&captive_private_bcb_map_object_info,0);
94 return captive_private_bcb_map_object_type;
97 CaptivePrivateBcbMapObject *captive_private_bcb_map_object_new(CaptiveSharedCacheMapObject *captive_shared_cache_map_object)
99 CaptivePrivateBcbMapObject *captive_private_bcb_map_object;
101 g_return_val_if_fail(CAPTIVE_SHARED_CACHE_MAP_IS_OBJECT(captive_shared_cache_map_object),NULL);
103 captive_private_bcb_map_object=g_object_new(
104 CAPTIVE_PRIVATE_BCB_MAP_TYPE_OBJECT, /* object_type */
105 NULL); /* first_property_name; FIXME: support properties */
107 _captive_private_bcb_object_connect_SharedCacheMap(CAPTIVE_PRIVATE_BCB_OBJECT(captive_private_bcb_map_object),
108 captive_shared_cache_map_object);
110 g_assert(captive_shared_cache_map_object->map==NULL);
111 captive_shared_cache_map_object->map=captive_private_bcb_map_object;
112 g_object_ref(captive_shared_cache_map_object); /* 'map' connected. */
114 return captive_private_bcb_map_object;
117 CaptivePrivateBcbMapObject *captive_private_bcb_map_object_get_ref
118 (CaptiveSharedCacheMapObject *captive_shared_cache_map_object)
120 g_return_val_if_fail(CAPTIVE_SHARED_CACHE_MAP_IS_OBJECT(captive_shared_cache_map_object),NULL);
122 if (captive_shared_cache_map_object->map) {
123 g_object_ref(captive_shared_cache_map_object->map);
124 return captive_shared_cache_map_object->map;
126 return captive_private_bcb_map_object_new(captive_shared_cache_map_object);