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);