gplate/gplate-collection.h
author Gary Kramlich <grim@reaperworld.com>
Sat Jul 03 23:24:33 2010 -0500 (22 months ago)
changeset 394 ad26d98e20e6
parent 291 310b912b92c7
permissions -rw-r--r--
Changed the license from gplv2 to gplv3
Updated copyrights to be 2007-2010 rather than 2007-2008 (since just about everything has been touched recently
Ignored the top level tests/ directory for now since that is slowly being replaced
     1 /*
     2  * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
     3  *
     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.
     8  *
     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.
    13  *
    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/>.
    16  */
    17 #ifndef GPLATE_COLLECTION_H
    18 #define GPLATE_COLLECTION_H
    19 
    20 #include <glib.h>
    21 #include <glib-object.h>
    22 
    23 #include <gplate/gplate-variable.h>
    24 
    25 #include <gplate/gplate-iterator.h>
    26 
    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))
    31 
    32 typedef struct _GPlateCollection			GPlateCollection;
    33 typedef struct _GPlateCollectionIface		GPlateCollectionIface;
    34 
    35 struct _GPlateCollectionIface {
    36 	GTypeInterface gparent;
    37 
    38 	GPlateVariable *(*find_variable)(const GPlateCollection *collection, const gchar *name);
    39 	gboolean (*add_variable_with_name)(GPlateCollection *collection, const gchar *name, GPlateVariable *variable);
    40 
    41 	gboolean (*remove_variable)(GPlateCollection *collection, GPlateVariable *variable);
    42 	gboolean (*remove_all)(GPlateCollection *collection);
    43 
    44 	GPlateIterator *(*get_iterator)(GPlateCollection *collection);
    45 
    46 	void (*_gplate_reserved1)(void);
    47 	void (*_gplate_reserved2)(void);
    48 	void (*_gplate_reserved3)(void);
    49 	void (*_gplate_reserved4)(void);
    50 };
    51 
    52 G_BEGIN_DECLS
    53 
    54 #define gplate_collection_add(collection, type, name, value) { \
    55 	GPlateVariable *var = NULL; \
    56 	\
    57 	var = gplate_variable_new_from_##type((name), (value)); \
    58 	gplate_collection_add_variable(GPLATE_COLLECTION(collection), (var));\
    59 }
    60 
    61 #define gplate_collection_add_string(collection, name, value) \
    62 	gplate_collection_add((collection), string, (name), (value));
    63 
    64 #define gplate_collection_add_boolean(collection, name, value) \
    65 	gplate_collection_add((collection), boolean, (name), (value));
    66 
    67 #define gplate_collection_add_integer(collection, name, value) \
    68 	gplate_collection_add((collection), integer, (name), (value));
    69 
    70 #define gplate_collection_add_float(collection, name, value) \
    71 	gplate_collection_add((collection), float, (name), (value));
    72 
    73 #define gplate_collection_add_double(collection, name, value) \
    74 	gplate_collection_add((collection), double, (name), (value));
    75 
    76 GType gplate_collection_get_gtype(void);
    77 
    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);
    82 
    83 gboolean gplate_collection_remove_variable(GPlateCollection *collection, GPlateVariable *variable);
    84 gboolean gplate_collection_remove_all(GPlateCollection *collection);
    85 
    86 GPlateIterator *gplate_collection_get_iterator(GPlateCollection *collection);
    87 
    88 G_END_DECLS
    89 
    90 #endif /* GPLATE_COLLECTION_H */