2 * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.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/>.
18 #ifndef __GIS_OBJECT_H__
19 #define __GIS_OBJECT_H__
22 #include <glib-object.h>
26 /* Take that GLib boilerplate! */
27 #define GOBJECT_HEAD( \
31 GType mam##_##bar##_get_type(void); \
32 typedef struct _##Mam##Bar Mam##Bar; \
33 typedef struct _##Mam##Bar##Class Mam##Bar##Class; \
34 static inline Mam##Bar *MAM##_##BAR(gpointer obj) { \
35 return G_TYPE_CHECK_INSTANCE_CAST(obj, MAM##_TYPE_##BAR, Mam##Bar); \
37 static inline gboolean MAM##_IS_##BAR(gpointer obj) { \
38 return G_TYPE_CHECK_INSTANCE_TYPE(obj, MAM##_TYPE_##BAR); \
40 static inline Mam##Bar##Class *MAM##_##BAR##_CLASS(gpointer klass) { \
41 return G_TYPE_CHECK_CLASS_CAST(klass, MAM##_TYPE_##BAR, Mam##Bar##Class); \
43 static inline gboolean MAM##_IS_##BAR##_CLASS(gpointer klass) { \
44 return G_TYPE_CHECK_CLASS_TYPE(klass, MAM##_TYPE_##BAR); \
46 static inline Mam##Bar##Class *MAM##_##BAR##_GET_CLASS(gpointer obj) { \
47 return G_TYPE_INSTANCE_GET_CLASS(obj, MAM##_TYPE_##BAR, Mam##Bar##Class); \
50 #define GOBJECT_BODY( \
55 G_DEFINE_TYPE(Mam##Bar, mam##_##bar, parent_type); \
56 static void mam##_##bar##_init(Mam##Bar *self) { \
58 static void mam##_##bar##_class_init(Mam##Bar##Class *klass) { \
60 static Mam##Bar *mam##_##bar##_new() { \
61 return g_object_new(MAM##_TYPE_##BAR, NULL); \
66 typedef struct _GisPoint GisPoint;
69 gdouble lat, lon, elev;
72 GisPoint *gis_point_new();
73 void gis_point_set_lle(GisPoint *point, gdouble lat, gdouble lon, gdouble elev);
74 void gis_point_free(GisPoint *point);
78 #define GIS_TYPE_OBJECT (gis_object_get_type())
86 GObject parent_instance;
91 struct _GisObjectClass {
92 GObjectClass parent_class;
95 static inline GisPoint *gis_object_center(GisObject *object)
97 return &GIS_OBJECT(object)->center;
102 #define GIS_TYPE_MARKER (gis_marker_get_type())
110 GisObject parent_instance;
117 struct _GisMarkerClass {
118 GisObjectClass parent_class;
121 GisMarker *gis_marker_new(const gchar *label);
125 #define GIS_TYPE_CALLBACK (gis_callback_get_type())
132 typedef gpointer (*GisCallbackFunc)(GisCallback *callback, gpointer user_data);
134 struct _GisCallback {
136 GisCallbackFunc callback;
140 struct _GisCallbackClass {
141 GisObjectClass parent_class;
144 GisCallback *gis_callback_new(GisCallbackFunc callback, gpointer user_data);