2 * matdb: generic materials database information.
6 Copyright (C) 2008 Joseph Pingenot
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 static void print_property(gpointer key, gpointer value, gpointer user_data) {
28 fprintf(stderr, "\t\t%s=%g:\n", (char*)key, *(double*)value);
30 static void print_material(gpointer key, gpointer value, gpointer user_data) {
31 struct matdb_material *mat = (struct matdb_material*)value;
32 fprintf(stderr, "\tmaterial %s(%s):\n", mat->name->str, (char*)key);
33 g_hash_table_foreach(mat->properties, print_property, NULL);
35 static void print_bowing(gpointer key, gpointer value, gpointer user_data) {
36 struct matdb_bowing *bowing = (struct matdb_bowing*)value;
37 fprintf(stderr, "\tbowing %s:%s(%s):\n", bowing->from->str, bowing->to->str, (char*)key);
38 g_hash_table_foreach(bowing->properties, print_property, NULL);
41 void print_matdb(const struct matdb *mdb) {
42 fprintf(stderr, "matdb:\n");
43 g_hash_table_foreach(mdb->materials, &print_material, NULL);
44 g_hash_table_foreach(mdb->bowings, &print_bowing, NULL);
47 void destroy_material_gpointer(gpointer data) {
48 destroy_material((struct matdb_material *)data);
50 void destroy_bowing_gpointer(gpointer data) {
51 destroy_bowing((struct matdb_bowing *)data);
53 void destroy_material(struct matdb_material *mat) {
55 g_hash_table_unref(mat->properties);
58 void destroy_bowing(struct matdb_bowing *bow) {
61 g_hash_table_unref(bow->properties);