32 typedef struct cell_record
36 CellCreateFunc creator;
41 GHashTable *cell_table;
46 gnc_cell_factory_new (
void)
50 cf = g_new0 (CellFactory, 1);
52 cf->cell_table = g_hash_table_new (g_str_hash, g_str_equal);
58 cell_table_destroy_helper (gpointer key, gpointer value, gpointer user_data)
62 g_free (cr->cell_type_name);
67 gnc_cell_factory_destroy (CellFactory *cf)
71 g_hash_table_foreach (cf->cell_table, cell_table_destroy_helper, NULL);
77 gnc_cell_factory_add_cell_type (CellFactory *cf,
78 const char *cell_type_name,
79 CellCreateFunc cell_creator)
83 g_return_if_fail (cell_type_name != NULL);
84 g_return_if_fail (cell_creator != NULL);
86 cr = g_hash_table_lookup (cf->cell_table, cell_type_name);
90 g_hash_table_remove (cf->cell_table, cell_type_name);
91 g_free (cr->cell_type_name);
96 cr->cell_type_name = g_strdup (cell_type_name);
97 cr->creator = cell_creator;
99 g_hash_table_insert (cf->cell_table, cr->cell_type_name, cr);
103 gnc_cell_factory_make_cell (CellFactory *cf,
const char *cell_type_name)
107 g_return_val_if_fail (cf != NULL, NULL);
108 g_return_val_if_fail (cell_type_name != NULL, NULL);
110 cr = g_hash_table_lookup (cf->cell_table, cell_type_name);
111 g_return_val_if_fail (cr != NULL, NULL);
113 return cr->creator ();
All type declarations for the whole Gnucash engine.