GnuCash  5.6-150-g038405b370+
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_CHOICE "choice" /* was moved from (deleted) qofchoice.h */
102 #define QOF_TYPE_COLLECT "collection"
132  typedef const char * QofType;
133 
134 typedef struct _QofParam QofParam;
135 
151 typedef gpointer (*QofAccessFunc)(gpointer object, /*@ null @*/ const QofParam *param);
152 
158 typedef void (*QofSetterFunc) (gpointer, /*@ null @*/ gpointer);
160 /* A callback for how to compare two (same-type) objects based on a
161  * common getter (parameter member), using the provided comparison
162  * options (which are the type-specific options).
163  */
164 typedef gint (*QofCompareFunc) (gpointer a, gpointer b,
165  gint compare_options,
166  QofParam *getter);
167 
185 struct _QofParam
186 {
187  const char * param_name;
188  QofType param_type;
189  QofAccessFunc param_getfcn;
190  QofSetterFunc param_setfcn;
191  QofCompareFunc param_compfcn;
192  gpointer param_userdata;
193 };
194 
196 typedef int (*QofSortFunc)(gconstpointer, gconstpointer);
197 
211 void qof_class_register (QofIdTypeConst obj_name,
212  QofSortFunc default_sort_fcn,
213  const QofParam *params);
214 
237 gboolean qof_class_is_registered (QofIdTypeConst obj_name);
238 
241  const char *param_name);
242 
244 const QofParam * qof_class_get_parameter (QofIdTypeConst obj_name,
245  const char *parameter);
246 
249  const char *parameter);
250 
253  const char *parameter);
254 
256 typedef void (*QofClassForeachCB) (QofIdTypeConst, gpointer);
257 
261 void qof_class_foreach (QofClassForeachCB, gpointer user_data);
262 
264 typedef void (*QofParamForeachCB) (QofParam *, gpointer user_data);
265 
270  QofParamForeachCB, gpointer user_data);
271 
279 
280 
281 #ifdef __cplusplus
282 }
283 #endif
284 
285 #endif /* QOF_CLASS_H */
286 
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:212
const char * QofType
Type of Parameters (String, Date, Numeric, GncGUID, etc.)
Definition: qofclass.h:159
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
Definition: qofid.h:82
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:283
int(* QofSortFunc)(gconstpointer, gconstpointer)
This function is the default sort function for a particular object type.
Definition: qofclass.h:223
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:185
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:178
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:291
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