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>
24 /* Take that GLib boilerplate! */
25 #define GOBJECT_HEAD( \
29 GType mam##_##bar##_get_type(void); \
30 typedef struct _##Mam##Bar Mam##Bar; \
31 typedef struct _##Mam##Bar##Class Mam##Bar##Class; \
32 static inline Mam##Bar *MAM##_##BAR(gpointer obj) { \
33 return G_TYPE_CHECK_INSTANCE_CAST(obj, MAM##_TYPE_##BAR, Mam##Bar); \
35 static inline gboolean MAM##_IS_##BAR(gpointer obj) { \
36 return G_TYPE_CHECK_INSTANCE_TYPE(obj, MAM##_TYPE_##BAR); \
38 static inline Mam##Bar##Class *MAM##_##BAR##_CLASS(gpointer klass) { \
39 return G_TYPE_CHECK_CLASS_CAST(klass, MAM##_TYPE_##BAR, Mam##Bar##Class); \
41 static inline gboolean MAM##_IS_##BAR##_CLASS(gpointer klass) { \
42 return G_TYPE_CHECK_CLASS_TYPE(klass, MAM##_TYPE_##BAR); \
44 static inline Mam##Bar##Class *MAM##_##BAR##_GET_CLASS(gpointer obj) { \
45 return G_TYPE_INSTANCE_GET_CLASS(obj, MAM##_TYPE_##BAR, Mam##Bar##Class); \
48 #define GOBJECT_BODY( \
53 G_DEFINE_TYPE(Mam##Bar, mam##_##bar, parent_type); \
54 static void mam##_##bar##_init(Mam##Bar *mambar) { \
56 static void mam##_##bar##_class_init(Mam##Bar##Class *klass) { \
58 static Mam##Bar *mam##_##bar##_new() { \
59 return g_object_new(MAM##_TYPE_##BAR, NULL); \
64 typedef struct _GisPoint GisPoint;
67 gdouble lat, lon, elev;
70 GisPoint *gis_point_new();
71 void gis_point_set_lle(GisPoint *point, gdouble lat, gdouble lon, gdouble elev);
72 void gis_point_free(GisPoint *point);
76 #define GIS_TYPE_OBJECT (gis_object_get_type())
84 GObject parent_instance;
89 struct _GisObjectClass {
90 GObjectClass parent_class;
93 static inline GisPoint *gis_object_center(GisObject *object)
95 return &GIS_OBJECT(object)->center;