mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add a parameter for-each function per request from Niel Williams
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10070 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9d453b6680
commit
4999b0b966
@ -186,4 +186,38 @@ qof_class_get_default_sort (QofIdTypeConst obj_name)
|
||||
return g_hash_table_lookup (sortTable, obj_name);
|
||||
}
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
struct _iterate {
|
||||
QofParamForeachCB fcn;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static void
|
||||
foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct _iterate *iter = arg;
|
||||
QofParam *parm = item;
|
||||
|
||||
iter->fcn (parm, iter->data);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qof_class_param_foreach (QofIdTypeConst obj_name,
|
||||
QofParamForeachCB cb, gpointer user_data)
|
||||
{
|
||||
struct _iterate iter;
|
||||
GHashTable *param_ht;
|
||||
|
||||
if (!obj_name || !cb) return;
|
||||
param_ht = g_hash_table_lookup (paramTable, obj_name);
|
||||
if (!param_ht) return;
|
||||
|
||||
iter.fcn = cb;
|
||||
iter.data = user_data;
|
||||
|
||||
g_hash_table_foreach (param_ht, foreach_cb, &iter);
|
||||
}
|
||||
|
||||
/* ============================= END OF FILE ======================== */
|
||||
|
@ -116,9 +116,9 @@ typedef void (*QofSetterFunc) (gpointer, gpointer);
|
||||
* object (QofIdType) or it can be a core data type (QofType).
|
||||
* -- param_getfcn is the function to actually obtain the parameter
|
||||
* -- param_setfcn is the function to actually set the parameter
|
||||
* -- param_userdata is a place where the user can place any desiered
|
||||
* user-defined data (and thus can be used by the user-defined
|
||||
* setter/getter).
|
||||
* -- param_userdata is a place where the object author can place any
|
||||
* desired object-author-defined data (and thus can be used by the
|
||||
* author-defined setter/getter).
|
||||
*
|
||||
* Either the getter or the setter may be NULL.
|
||||
*
|
||||
@ -195,6 +195,15 @@ QofAccessFunc qof_class_get_parameter_getter (QofIdTypeConst obj_name,
|
||||
QofSetterFunc qof_class_get_parameter_setter (QofIdTypeConst obj_name,
|
||||
const char *parameter);
|
||||
|
||||
/** Type definition for the paramter callback function. */
|
||||
typedef void (*QofParamForeachCB) (QofParam *, gpointer user_data);
|
||||
|
||||
/** Call the callback once for each parameter on the indicated
|
||||
* object class. The 'user_data' is passed back to teh callback.
|
||||
*/
|
||||
void qof_class_param_foreach (QofIdTypeConst obj_name,
|
||||
QofParamForeachCB, gpointer user_data);
|
||||
|
||||
|
||||
#endif /* QOF_CLASS_H */
|
||||
/* @} */
|
||||
|
Loading…
Reference in New Issue
Block a user