1507
|
1 /* Paranormal - A highly customizable audio visualization library
|
|
2 * Copyright (C) 2001 Jamie Gennis <jgennis@mindspring.com>
|
|
3 *
|
|
4 * This library is free software; you can redistribute it and/or
|
|
5 * modify it under the terms of the GNU Library General Public
|
|
6 * License as published by the Free Software Foundation; either
|
|
7 * version 2 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 * Library General Public License for more details.
|
|
13 *
|
|
14 * You should have received a copy of the GNU Library General Public
|
|
15 * License along with this library; if not, write to the Free
|
|
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17 */
|
|
18
|
|
19 #ifndef __PN_OBJECT_H__
|
|
20 #define __PN_OBJECT_H__
|
|
21
|
|
22 #include <config.h>
|
|
23
|
|
24 #include <glib.h>
|
|
25 #include <glib-object.h>
|
|
26
|
|
27 G_BEGIN_DECLS
|
|
28
|
|
29 #define PN_TYPE_OBJECT (pn_object_get_type ())
|
|
30 #define PN_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PN_TYPE_OBJECT, PnObject))
|
|
31 #define PN_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), PN_TYPE_OBJECT, PnObjectClass))
|
|
32 #define PN_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PN_TYPE_OBJECT))
|
|
33 #define PN_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), PN_TYPE_OBJECT))
|
|
34 #define PN_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PN_TYPE_OBJECT, PnObjectClass))
|
|
35 #define PN_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
|
|
36 #define PN_OBJECT_CLASS_NAME(class) (g_type_name (PN_OBJECT_CLASS_TYPE (class)))
|
|
37
|
|
38 #define PN_OBJECT_TYPE(obj) (G_TYPE_FROM_INSTANCE (obj))
|
|
39 #define PN_OBJECT_TYPE_NAME(obj) (g_type_name (PN_OBJECT_TYPE (obj)))
|
|
40
|
|
41 typedef enum
|
|
42 {
|
|
43 PN_DESTROYED = 1 << 0,
|
|
44 PN_FLOATING = 1 << 1,
|
|
45 PN_RESERVED_1 = 1 << 2,
|
|
46 PN_RESERVED_2 = 1 << 3
|
|
47 } PnObjectFlags;
|
|
48
|
|
49 #define PN_OBJECT_FLAGS(obj) (PN_OBJECT (obj)->flags)
|
|
50 #define PN_OBJECT_DESTROYED(obj) ((PN_OBJECT_FLAGS (obj) & PN_DESTROYED) != 0)
|
|
51 #define PN_OBJECT_FLOATING(obj) ((PN_OBJECT_FLAGS (obj) & PN_FLOATING) != 0)
|
|
52 #define PN_OBJECT_CONNECTED(obj) ((PN_OBJECT_FLAGS (obj) & PN_CONNECTED) != 0)
|
|
53
|
|
54 #define PN_OBJECT_SET_FLAGS(obj,flag) G_STMT_START{ (PN_OBJECT_FLAGS (obj) |= (flag)); }G_STMT_END
|
|
55 #define PN_OBJECT_UNSET_FLAGS(obj,flag) G_STMT_START{ (PN_OBJECT_FLAGS (obj) &= ~(flag)); }G_STMT_END
|
|
56
|
|
57 typedef struct _PnObject PnObject;
|
|
58 typedef struct _PnObjectClass PnObjectClass;
|
|
59
|
|
60 struct _PnObject
|
|
61 {
|
|
62 GObject parent;
|
|
63
|
|
64 /* Only the first four bits are used, so derived classes can use this
|
|
65 * for their own flags
|
|
66 */
|
|
67 guint32 flags;
|
|
68 };
|
|
69
|
|
70 struct _PnObjectClass
|
|
71 {
|
|
72 GObjectClass parent_class;
|
|
73
|
|
74 /* if a class overrides this then it MUST call its superclass'
|
|
75 * implimentation
|
|
76 */
|
|
77 void (*destroy) (PnObject *object);
|
|
78 };
|
|
79
|
|
80 /* Creators */
|
|
81 GType pn_object_get_type (void);
|
|
82
|
|
83 /* Referencing */
|
|
84 PnObject* pn_object_ref (PnObject *object);
|
|
85 void pn_object_unref (PnObject *object);
|
|
86 void pn_object_sink (PnObject *object);
|
|
87
|
|
88 /* Destruction */
|
|
89 void pn_object_destroy (PnObject *object);
|
|
90
|
|
91 #endif /* __PN_OBJECT_H__ */
|