Bug 22803 - Make header conform to implementation
[swfdec.git] / swfdec / swfdec_cached.c
blob5920385e1e05e49174716a5ba6fc7fb5b7aab856
1 /* Swfdec
2 * Copyright (C) 2008 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include "swfdec_cached.h"
25 #include "swfdec_debug.h"
28 G_DEFINE_ABSTRACT_TYPE (SwfdecCached, swfdec_cached, G_TYPE_OBJECT)
30 enum {
31 PROP_0,
32 PROP_SIZE
35 enum {
36 USE,
37 UNUSE,
38 LAST_SIGNAL
41 static guint signals[LAST_SIGNAL] = { 0, };
43 static void
44 swfdec_cached_get_property (GObject *object, guint param_id, GValue *value,
45 GParamSpec *pspec)
47 SwfdecCached *cached = SWFDEC_CACHED (object);
49 switch (param_id) {
50 case PROP_SIZE:
51 g_value_set_ulong (value, cached->size);
52 break;
53 default:
54 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
55 break;
59 static void
60 swfdec_cached_set_property (GObject *object, guint param_id, const GValue *value,
61 GParamSpec *pspec)
63 SwfdecCached *cached = SWFDEC_CACHED (object);
65 switch (param_id) {
66 case PROP_SIZE:
67 cached->size = g_value_get_ulong (value);
68 break;
69 default:
70 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
71 break;
75 static void
76 swfdec_cached_class_init (SwfdecCachedClass * g_class)
78 GObjectClass *object_class = G_OBJECT_CLASS (g_class);
80 object_class->get_property = swfdec_cached_get_property;
81 object_class->set_property = swfdec_cached_set_property;
83 /* FIXME: should be g_param_spec_size(), but no such thing exists */
84 g_object_class_install_property (object_class, PROP_SIZE,
85 g_param_spec_ulong ("size", "size", "size of this object in bytes",
86 0, G_MAXULONG, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
88 signals[USE] = g_signal_new ("use", G_TYPE_FROM_CLASS (g_class),
89 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
90 G_TYPE_NONE, 0);
91 signals[UNUSE] = g_signal_new ("unuse", G_TYPE_FROM_CLASS (g_class),
92 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
93 G_TYPE_NONE, 0);
96 static void
97 swfdec_cached_init (SwfdecCached * cached)
99 cached->size = sizeof (SwfdecCached);
102 void
103 swfdec_cached_use (SwfdecCached *cached)
105 g_return_if_fail (SWFDEC_IS_CACHED (cached));
107 g_signal_emit (cached, signals[USE], 0);
110 void
111 swfdec_cached_unuse (SwfdecCached *cached)
113 g_return_if_fail (SWFDEC_IS_CACHED (cached));
115 g_signal_emit (cached, signals[UNUSE], 0);
118 gsize
119 swfdec_cached_get_size (SwfdecCached *cached)
121 g_return_val_if_fail (SWFDEC_IS_CACHED (cached), 0);
123 return cached->size;