GnuCash 2.4.99
qofclass.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * qofclass.h -- API for registering parameters on objects          *
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, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00022 
00069 #ifndef QOF_CLASS_H
00070 #define QOF_CLASS_H
00071 
00072 #include "qofid.h"
00073 
00074 #define QOF_MOD_CLASS "qof.class"
00075 
00085 #define QOF_TYPE_STRING    "string"
00086 #define QOF_TYPE_DATE      "date"
00087 #define QOF_TYPE_NUMERIC   "numeric"
00088 #define QOF_TYPE_DEBCRED   "debcred"
00089 #define QOF_TYPE_GUID      "guid"
00090 #define QOF_TYPE_INT32     "gint32"
00091 #define QOF_TYPE_INT64     "gint64"
00092 #define QOF_TYPE_DOUBLE    "double"
00093 #define QOF_TYPE_BOOLEAN   "boolean"
00094 #define QOF_TYPE_KVP       "kvp"
00095 #define QOF_TYPE_CHAR      "character"
00096 #define QOF_TYPE_COLLECT   "collection" 
00126                 typedef const char * QofType;
00127 
00128 typedef struct _QofParam QofParam;
00129 
00145 typedef gpointer (*QofAccessFunc)(gpointer object, /*@ null @*/ const QofParam *param);
00146 
00152 typedef void (*QofSetterFunc) (gpointer, /*@ null @*/ gpointer);
00153 
00154 /* A callback for how to compare two (same-type) objects based on a
00155  * common getter (parameter member), using the provided comparison
00156  * options (which are the type-specific options).
00157  */
00158 typedef gint (*QofCompareFunc) (gpointer a, gpointer b,
00159                                 gint compare_options,
00160                                 QofParam *getter);
00161 
00179 struct _QofParam
00180 {
00181     const char       * param_name;
00182     QofType            param_type;
00183     QofAccessFunc      param_getfcn;
00184     QofSetterFunc      param_setfcn;
00185     QofCompareFunc     param_compfcn;
00186     gpointer           param_userdata;
00187 };
00188 
00190 typedef int (*QofSortFunc)(gconstpointer, gconstpointer);
00191 
00205 void qof_class_register (QofIdTypeConst obj_name,
00206                          QofSortFunc default_sort_fcn,
00207                          const QofParam *params);
00208 
00231 gboolean qof_class_is_registered (QofIdTypeConst obj_name);
00232 
00234 QofType qof_class_get_parameter_type (QofIdTypeConst obj_name,
00235                                       const char *param_name);
00236 
00238 const QofParam * qof_class_get_parameter (QofIdTypeConst obj_name,
00239         const char *parameter);
00240 
00242 QofAccessFunc qof_class_get_parameter_getter (QofIdTypeConst obj_name,
00243         const char *parameter);
00244 
00246 QofSetterFunc qof_class_get_parameter_setter (QofIdTypeConst obj_name,
00247         const char *parameter);
00248 
00250 typedef void (*QofClassForeachCB) (QofIdTypeConst, gpointer);
00251 
00255 void qof_class_foreach (QofClassForeachCB, gpointer user_data);
00256 
00258 typedef void (*QofParamForeachCB) (QofParam *, gpointer user_data);
00259 
00263 void qof_class_param_foreach (QofIdTypeConst obj_name,
00264                               QofParamForeachCB, gpointer user_data);
00265 
00272 GList* qof_class_get_referenceList(QofIdTypeConst type);
00273 
00274 
00275 #endif /* QOF_CLASS_H */
00276 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines