GnuCash  4.8a-80-g9825132ea+
qofclass.h
Go to the documentation of this file.
1 /********************************************************************\
2  * qofclass.h -- API for registering parameters on objects *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program 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 *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA gnu@gnu.org *
20  * *
21 \********************************************************************/
22 
69 #ifndef QOF_CLASS_H
70 #define QOF_CLASS_H
71 
72 #include "qofid.h"
73 
74 #ifdef __cplusplus
75 extern "C"
76 {
77 #endif
78 
79 #define QOF_MOD_CLASS "qof.class"
80 
90 #define QOF_TYPE_STRING "string"
91 #define QOF_TYPE_DATE "date"
92 #define QOF_TYPE_NUMERIC "numeric"
93 #define QOF_TYPE_DEBCRED "debcred"
94 #define QOF_TYPE_GUID "guid"
95 #define QOF_TYPE_INT32 "gint32"
96 #define QOF_TYPE_INT64 "gint64"
97 #define QOF_TYPE_DOUBLE "double"
98 #define QOF_TYPE_BOOLEAN "boolean"
99 #define QOF_TYPE_KVP "kvp"
100 #define QOF_TYPE_CHAR "character"
101 #define QOF_TYPE_COLLECT "collection"
131  typedef const char * QofType;
132 
133 typedef struct _QofParam QofParam;
134 
150 typedef gpointer (*QofAccessFunc)(gpointer object, /*@ null @*/ const QofParam *param);
151 
157 typedef void (*QofSetterFunc) (gpointer, /*@ null @*/ gpointer);
159 /* A callback for how to compare two (same-type) objects based on a
160  * common getter (parameter member), using the provided comparison
161  * options (which are the type-specific options).
162  */
163 typedef gint (*QofCompareFunc) (gpointer a, gpointer b,
164  gint compare_options,
165  QofParam *getter);
166 
184 struct _QofParam
185 {
186  const char * param_name;
187  QofType param_type;
188  QofAccessFunc param_getfcn;
189  QofSetterFunc param_setfcn;
190  QofCompareFunc param_compfcn;
191  gpointer param_userdata;
192 };
193 
195 typedef int (*QofSortFunc)(gconstpointer, gconstpointer);
196 
210 void qof_class_register (QofIdTypeConst obj_name,
211  QofSortFunc default_sort_fcn,
212  const QofParam *params);
213 
236 gboolean qof_class_is_registered (QofIdTypeConst obj_name);
237 
240  const char *param_name);
241 
243 const QofParam * qof_class_get_parameter (QofIdTypeConst obj_name,
244  const char *parameter);
245 
248  const char *parameter);
249 
252  const char *parameter);
253 
255 typedef void (*QofClassForeachCB) (QofIdTypeConst, gpointer);
256 
260 void qof_class_foreach (QofClassForeachCB, gpointer user_data);
261 
263 typedef void (*QofParamForeachCB) (QofParam *, gpointer user_data);
264 
269  QofParamForeachCB, gpointer user_data);
270 
278 
279 
280 #ifdef __cplusplus
281 }
282 #endif
283 
284 #endif /* QOF_CLASS_H */
285 
gboolean qof_class_is_registered(QofIdTypeConst obj_name)
An example:
Definition: qofclass.cpp:125
void qof_class_param_foreach(QofIdTypeConst obj_name, QofParamForeachCB, gpointer user_data)
Call the callback once for each parameter on the indicated object class.
Definition: qofclass.cpp:250
This structure is for each queryable parameter in an object.
Definition: qofclass.h:211
const char * QofType
Type of Parameters (String, Date, Numeric, GncGUID, etc.)
Definition: qofclass.h:158
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
Definition: qofid.h:87
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_fcn, const QofParam *params)
This function registers a new object class with the Qof subsystem.
Definition: qofclass.cpp:86
void(* QofClassForeachCB)(QofIdTypeConst, gpointer)
Type definition for the class callback function.
Definition: qofclass.h:282
int(* QofSortFunc)(gconstpointer, gconstpointer)
This function is the default sort function for a particular object type.
Definition: qofclass.h:222
QOF entity type identification system.
QofAccessFunc qof_class_get_parameter_getter(QofIdTypeConst obj_name, const char *parameter)
Return the object's parameter getter function.
Definition: qofclass.cpp:156
void(* QofSetterFunc)(gpointer, gpointer)
The QofSetterFunc defines an function pointer for parameter setters.
Definition: qofclass.h:184
const QofParam * qof_class_get_parameter(QofIdTypeConst obj_name, const char *parameter)
Return the registered Parameter Definition for the requested parameter.
Definition: qofclass.cpp:136
void qof_class_foreach(QofClassForeachCB, gpointer user_data)
Call the callback once for each object class that is registered with the system.
Definition: qofclass.cpp:219
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
Definition: qofclass.h:177
GList * qof_class_get_referenceList(QofIdTypeConst type)
List of the parameters that could be references.
Definition: qofclass.cpp:334
QofSetterFunc qof_class_get_parameter_setter(QofIdTypeConst obj_name, const char *parameter)
Return the object's parameter setter function.
Definition: qofclass.cpp:172
void(* QofParamForeachCB)(QofParam *, gpointer user_data)
Type definition for the parameter callback function.
Definition: qofclass.h:290
QofType qof_class_get_parameter_type(QofIdTypeConst obj_name, const char *param_name)
Return the core datatype of the specified object's parameter.
Definition: qofclass.cpp:188