GnuCash 2.4.99
gnc-basic-gobject.h
00001 /********************************************************************\
00002  * gnc-basic-gobject.h                                              *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, write to the Free Software      *
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.        *
00017 \********************************************************************/
00018 
00019 
00020 #ifndef GNC_BASIC_GOBJECT_H
00021 #define GNC_BASIC_GOBJECT_H
00022 
00023 /* A simple macro to define simple gobjects */
00024 
00025 #define GNC_BASIC_GOBJECT_TYPE(type_struct,klass_struct,parent,klass_init,inst_init,get_type_fcn)       \
00026 GType                                                                           \
00027 get_type_fcn (void)                                                             \
00028 {                                                                               \
00029   static GType type = 0;                                                        \
00030                                                                                 \
00031   if (type == 0) {                                                              \
00032     GTypeInfo type_info = {                                                     \
00033       sizeof (klass_struct),                                                    \
00034       NULL,                                                                     \
00035       NULL,                                                                     \
00036       (GClassInitFunc) klass_init,                                              \
00037       NULL,                                                                     \
00038       NULL,                                                                     \
00039       sizeof (type_struct),                                                     \
00040       0,                                                                        \
00041       (GInstanceInitFunc) inst_init,                                            \
00042     };                                                                          \
00043                                                                                 \
00044     type = g_type_register_static (parent, #type_struct, &type_info, 0);        \
00045   }                                                                             \
00046                                                                                 \
00047   return type;                                                                  \
00048 }
00049 
00050 #define GNC_BASIC_GOBJECT_NEW(type_struct,new_fcn,get_type_fcn)                 \
00051 type_struct *                                                                   \
00052 new_fcn (void)                                                                  \
00053 {                                                                               \
00054   return (type_struct *) g_object_new(get_type_fcn (), NULL);                   \
00055 }
00056 
00057 #define GNC_BASIC_GOBJECT(type_struct,klass_struct,parent,klass_init,inst_init,get_type_fcn,new_fcn)    \
00058 GNC_BASIC_GOBJECT_TYPE(type_struct,klass_struct,parent,klass_init,inst_init,get_type_fcn) \
00059 GNC_BASIC_GOBJECT_NEW(type_struct,new_fcn,get_type_fcn)
00060 
00061 #endif /* GNC_BASIC_GOBJECT_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines