2 * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef GPLATE_COLLECTION_H
18 #define GPLATE_COLLECTION_H
21 #include <glib-object.h>
23 #include <gplate/gplate-variable.h>
25 #include <gplate/gplate-iterator.h>
27 #define GPLATE_TYPE_COLLECTION (gplate_collection_get_gtype())
28 #define GPLATE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GPLATE_TYPE_COLLECTION, GPlateCollection))
29 #define GPLATE_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GPLATE_TYPE_COLLECTION))
30 #define GPLATE_COLLECTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), GPLATE_TYPE_COLLECTION, GPlateCollectionIface))
32 typedef struct _GPlateCollection GPlateCollection;
33 typedef struct _GPlateCollectionIface GPlateCollectionIface;
35 struct _GPlateCollectionIface {
36 GTypeInterface gparent;
38 GPlateVariable *(*find_variable)(const GPlateCollection *collection, const gchar *name);
39 gboolean (*add_variable_with_name)(GPlateCollection *collection, const gchar *name, GPlateVariable *variable);
41 gboolean (*remove_variable)(GPlateCollection *collection, GPlateVariable *variable);
42 gboolean (*remove_all)(GPlateCollection *collection);
44 GPlateIterator *(*get_iterator)(GPlateCollection *collection);
46 void (*_gplate_reserved1)(void);
47 void (*_gplate_reserved2)(void);
48 void (*_gplate_reserved3)(void);
49 void (*_gplate_reserved4)(void);
54 #define gplate_collection_add(collection, type, name, value) { \
55 GPlateVariable *var = NULL; \
57 var = gplate_variable_new_from_##type((name), (value)); \
58 gplate_collection_add_variable(GPLATE_COLLECTION(collection), (var));\
61 #define gplate_collection_add_string(collection, name, value) \
62 gplate_collection_add((collection), string, (name), (value));
64 #define gplate_collection_add_boolean(collection, name, value) \
65 gplate_collection_add((collection), boolean, (name), (value));
67 #define gplate_collection_add_integer(collection, name, value) \
68 gplate_collection_add((collection), integer, (name), (value));
70 #define gplate_collection_add_float(collection, name, value) \
71 gplate_collection_add((collection), float, (name), (value));
73 #define gplate_collection_add_double(collection, name, value) \
74 gplate_collection_add((collection), double, (name), (value));
76 GType gplate_collection_get_gtype(void);
78 GPlateVariable *gplate_collection_find_variable(const GPlateCollection *collection, const gchar *name);
79 const gchar *gplate_collection_lookup(const GPlateCollection *collection, const gchar *name);
80 gboolean gplate_collection_add_variable(GPlateCollection *collection, GPlateVariable *variable);
81 gboolean gplate_collection_add_variable_with_name(GPlateCollection *collection, const gchar *name, GPlateVariable *variable);
83 gboolean gplate_collection_remove_variable(GPlateCollection *collection, GPlateVariable *variable);
84 gboolean gplate_collection_remove_all(GPlateCollection *collection);
86 GPlateIterator *gplate_collection_get_iterator(GPlateCollection *collection);
90 #endif /* GPLATE_COLLECTION_H */