35 struct QofCollection_s
40 GHashTable *hash_of_entities;
46 static void qof_collection_remove_entity (
QofEntity * ent);
51 g_return_if_fail (NULL != tab);
57 PERR (
"attempt to insert \"%s\" into \"%s\"", type, tab->e_type);
60 ent->e_type = CACHE_INSERT (type);
69 PWARN (
"duplicate id created, trying again");
73 ent->collection = tab;
83 qof_collection_remove_entity (ent);
84 CACHE_REMOVE (ent->e_type);
98 col = ent->collection;
99 qof_collection_remove_entity (ent);
115 id_compare (gconstpointer key_1, gconstpointer key_2)
125 col->e_type = CACHE_INSERT (type);
134 CACHE_REMOVE (col->e_type);
135 g_hash_table_destroy (col->hash_of_entities);
137 col->hash_of_entities = NULL;
154 qof_collection_remove_entity (
QofEntity * ent)
159 col = ent->collection;
162 g_hash_table_remove (col->hash_of_entities, &ent->guid);
163 qof_collection_mark_dirty (col);
164 ent->collection = NULL;
174 g_return_if_fail (col->e_type == ent->e_type);
175 qof_collection_remove_entity (ent);
176 g_hash_table_insert (col->hash_of_entities, &ent->guid, ent);
177 qof_collection_mark_dirty (col);
178 ent->collection = col;
195 g_return_val_if_fail (coll->e_type == ent->e_type, FALSE);
201 g_hash_table_insert (coll->hash_of_entities, &ent->guid, ent);
202 qof_collection_mark_dirty (coll);
207 collection_merge_cb (
QofEntity * ent, gpointer data)
218 if (!target || !merge)
222 g_return_val_if_fail (target->e_type == merge->e_type, FALSE);
228 collection_compare_cb (
QofEntity * ent, gpointer user_data)
251 g_return_if_fail (target->e_type == ent->e_type);
269 if (!target && !merge)
273 if (!target && merge)
275 if (target && !merge)
277 if (target->e_type != merge->e_type)
295 g_return_val_if_fail (col, NULL);
298 ent = g_hash_table_lookup (col->hash_of_entities, guid);
310 for (list = glist; list != NULL; list = list->next)
326 c = g_hash_table_size (col->hash_of_entities);
335 return col ? col->is_dirty : FALSE;
343 col->is_dirty = FALSE;
352 col->is_dirty = TRUE;
361 return col ? col->data : NULL;
369 col->data = user_data;
382 foreach_cb (gpointer key __attribute__ ((unused)), gpointer item,
385 struct _iterate *qiter = arg;
388 qiter->fcn (ent, qiter->data);
395 struct _iterate qiter;
397 g_return_if_fail (col);
398 g_return_if_fail (cb_func);
401 qiter.data = user_data;
403 g_hash_table_foreach (col->hash_of_entities, foreach_cb, &qiter);
gboolean qof_collection_add_entity(QofCollection *coll, QofEntity *ent)
Add an entity to a QOF_TYPE_COLLECT.
gboolean guid_equal(const GUID *guid_1, const GUID *guid_2)
#define PERR(format, args...)
gint qof_collection_compare(QofCollection *target, QofCollection *merge)
Compare two secondary collections.
const GUID * guid_null(void)
gboolean qof_collection_is_dirty(QofCollection *col)
void(* QofEntityForeachCB)(QofEntity *, gpointer user_data)
struct QofCollection_s QofCollection
QofCollection * qof_collection_from_glist(QofIdType type, GList *glist)
Create a secondary collection from a GList.
guint qof_collection_count(QofCollection *col)
QofEntity * qof_collection_lookup_entity(QofCollection *col, const GUID *guid)
void qof_collection_foreach(QofCollection *col, QofEntityForeachCB cb_func, gpointer user_data)
void qof_collection_set_data(QofCollection *col, gpointer user_data)
void qof_entity_release(QofEntity *ent)
void qof_collection_mark_clean(QofCollection *col)
guint guid_hash_to_guint(gconstpointer ptr)
QofIdType qof_collection_get_type(QofCollection *col)
void guid_new(GUID *guid)
gpointer qof_collection_get_data(QofCollection *col)
#define PWARN(format, args...)
void qof_collection_destroy(QofCollection *col)
const GUID * qof_entity_get_guid(QofEntity *ent)
QofCollection * qof_collection_new(QofIdType type)
gboolean qof_collection_merge(QofCollection *target, QofCollection *merge)
Merge two QOF_TYPE_COLLECT of the same type.
void qof_entity_set_guid(QofEntity *ent, const GUID *guid)
gint safe_strcmp(const gchar *da, const gchar *db)
void qof_entity_init(QofEntity *ent, QofIdType type, QofCollection *tab)
const gchar * QofLogModule
void qof_collection_insert_entity(QofCollection *col, QofEntity *ent)