GnuCash  4.901
gnc-gobject-utils.h
Go to the documentation of this file.
1 /*
2  * gnc-gobject-utils.h -- utility functions for working
3  * with GObjects
4  * Copyright (C) 2005 David Hampton <hampton@employees.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, contact:
18  *
19  * Free Software Foundation Voice: +1-617-542-5942
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
21  * Boston, MA 02110-1301, USA gnu@gnu.org
22  */
23 
38 #ifndef GNC_GOBJECT_UTILS_H
39 #define GNC_GOBJECT_UTILS_H
40 
41 #include <glib.h>
42 #include <glib-object.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
86 void gnc_gobject_tracking_remember (GObject *object, GObjectClass *klass);
87 
92 void gnc_gobject_tracking_forget (GObject *object);
93 
103 const GList *gnc_gobject_tracking_get_list (const gchar *name);
104 
105 
112 void gnc_gobject_tracking_dump (void);
113 
124 #define GNC_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) { \
125  const GInterfaceInfo g_implement_interface_info = { \
126  (GInterfaceInitFunc)(void (*)(void *, void *)) iface_init, NULL, NULL \
127  }; \
128  g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
129 }
130 
131 #define GNC_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _GNC_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _GNC_DEFINE_TYPE_EXTENDED_END()
132 
133 #define _GNC_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
134 \
135 static void type_name##_init (TypeName *self, void *klass); \
136 static void type_name##_class_init (TypeName##Class *klass); \
137 static gpointer type_name##_parent_class = NULL; \
138 static gint TypeName##_private_offset; \
139 \
140 _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
141 \
142 G_GNUC_UNUSED \
143 static inline gpointer \
144 type_name##_get_instance_private (TypeName *self) \
145 { \
146  return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \
147 } \
148 \
149 GType \
150 type_name##_get_type (void) \
151 { \
152  static gsize g_define_type_id_static = 0; \
153  if (g_once_init_enter (&g_define_type_id_static)) \
154  { \
155  GType g_define_type_id = \
156  g_type_register_static_simple (TYPE_PARENT, \
157  g_intern_static_string (#TypeName), \
158  sizeof (TypeName##Class), \
159  (GClassInitFunc) type_name##_class_intern_init, \
160  sizeof (TypeName), \
161  (GInstanceInitFunc) type_name##_init, \
162  (GTypeFlags) flags); \
163  { /* custom code follows */
164 #define _GNC_DEFINE_TYPE_EXTENDED_END() \
165  /* following custom code */ \
166  } \
167  g_once_init_leave (&g_define_type_id_static, g_define_type_id); \
168  } \
169  return g_define_type_id_static; \
170 } /* closes type_name##_get_type() */
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 
177 #endif /* GNC_GOBJECT_UTILS_H */
178 
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
void gnc_gobject_tracking_dump(void)
Dump the entire object tracking database via the g_log() family of functions.
void gnc_gobject_tracking_remember(GObject *object, GObjectClass *klass)
Tell gnucash to remember this object in the database.
void gnc_gobject_tracking_forget(GObject *object)
Tell gnucash to drop this object from the database.